[Bio] / ModelEditor / PasswordDialog.py Repository:
ViewVC logotype

View of /ModelEditor/PasswordDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Oct 28 14:46:21 2004 UTC (14 years, 10 months ago) by efrank
Branch: MAIN
CVS Tags: post-st-migration2, pre-wxPython-2515-migration, sc04-finalDay, post-st-migration, before-dynamics-persistence, sc2004-1, sc2004-3, lwc, sc2004-4, treatman-lastDay-0, sc2004-2, preTreatmanDyn, sc2004-0, HEAD
!$

#-----------------------------------------------------------------------------
# Name:        PasswordDialog.py
#
# Purpose:
#
#    A widget to get a password via wxPython.
#
# History:
#              27Oct04 efrank      First version
#
# Bugs:
#
# RCS-ID:      $Id: PasswordDialog.py,v 1.1 2004/10/28 14:46:21 efrank Exp $
# Copyright:   (c) 2004
# Licence:     See COPYING.TXT
#-----------------------------------------------------------------------------
"""
"""
__revision__ = "$Id: PasswordDialog.py,v 1.1 2004/10/28 14:46:21 efrank Exp $"
__docformat__ = "restructuredtext en"


from wxPython.wx import *

#------------------------------------------------------------------------
def getPasswordByWx(parent, title, prompt):
#------------------------------------------------------------------------

    dlg = PasswordDialog(parent, title, prompt)
    if ( dlg.ShowModal() == wxID_OK):
        val = dlg.GetValue()
        dlg.Destroy()
        return val
    else:
        #didn't get a kid name
        dlg.Destroy()
        return None
    

#------------------------------------------------------------------------
class PasswordDialog(wxDialog):
#------------------------------------------------------------------------
    def __init__(self, parent, title="Password Entry",
                 prompt="Password",
                 pos=wxDefaultPosition, size=wxDefaultSize,
                 style=wxDEFAULT_DIALOG_STYLE):

        wxDialog.__init__(self, parent, -1, title, pos, size, style)

        l2 = wxStaticText(self, -1, prompt)
        self.textCtl = wxTextCtrl(self, -1, "", size=(125, -1), style=wxTE_PASSWORD)

        b = wxButton(self, -1, "OK")
        EVT_BUTTON(self, b.GetId(), self.onOK)
        b2 = wxButton(self, -1, "Cancel")
        EVT_BUTTON(self, b2.GetId(), self.onCancel)

        inputSizer = wxBoxSizer(wxVERTICAL)
        inputSizer.Add(l2, 0, wxGROW|wxALL, 4)
        inputSizer.Add(self.textCtl, 0, wxGROW|wxALL, 4)

        buttonSizer = wxBoxSizer(wxHORIZONTAL)
        buttonSizer.Add(b, 0, wxGROW|wxALL, 4)
        buttonSizer.Add(b2, 0, wxGROW|wxALL, 4)

        border = wxBoxSizer(wxVERTICAL)
        border.Add(inputSizer, 0, wxALL, 25)
        border.Add(buttonSizer, 0, wxALL, 25)

        self.SetSizer(border)
        self.SetAutoLayout(True)

        return

    #------------------------------------------------------------------------
    def GetValue( self):
    #------------------------------------------------------------------------
        return self.textCtl.GetValue()

    #------------------------------------------------------------------------
    def onCancel(self, evt):
    #------------------------------------------------------------------------
        self.EndModal(wxID_CANCEL)
        return

    #------------------------------------------------------------------------
    def onOK(self, evt):
    #------------------------------------------------------------------------
        self.EndModal(wxID_OK)
        return



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3