python 2.7 - wxPython Password, TextCtrol(TE_PASSWORD) isn't allowing ID_OK -
trying password application process here, way can id_ok
, cancel
buttons display in frame make dialog. have no problem doing this, think looks nicer, can't dialog accept te_password
or otherwise hide characters typed.
here i'm doing:
dlg = wx.textentrydialog(self, 'please enter password.','password prompt') if dlg.showmodal() == wx.id_ok: password = dlg.getvalue() msg = "please enter password." title = 'request email verification' password = password dlg.destroy()
if add te_password
dlg =
wx.id_ok
ignored. toughts?
create wx.dialog instead. can put text control on using wx.te_password style mentioned. can add button , set id wx.id_ok. following should work:
import wx ######################################################################## class logindialog(wx.dialog): """""" #---------------------------------------------------------------------- def __init__(self): """constructor""" wx.dialog.__init__(self, none, title="login") self.mainsizer = wx.boxsizer(wx.vertical) btnsizer = wx.boxsizer(wx.horizontal) userlbl = wx.statictext(self, label="username:") usertxt = wx.textctrl(self) self.addwidgets(userlbl, usertxt) passlbl = wx.statictext(self, label="password:") passtxt = wx.textctrl(self, style=wx.te_password) self.addwidgets(passlbl, passtxt) okbtn = wx.button(self, wx.id_ok) btnsizer.add(okbtn, 0, wx.center|wx.all, 5) cancelbtn = wx.button(self, wx.id_cancel) btnsizer.add(cancelbtn, 0, wx.center|wx.all, 5) self.mainsizer.add(btnsizer, 0, wx.center) self.setsizer(self.mainsizer) #---------------------------------------------------------------------- def addwidgets(self, lbl, txt): """ """ sizer = wx.boxsizer(wx.horizontal) sizer.add(lbl, 0, wx.all|wx.center, 5) sizer.add(txt, 1, wx.expand|wx.all, 5) self.mainsizer.add(sizer, 0, wx.expand) if __name__ == "__main__": app = wx.app(false) dlg = logindialog() dlg.showmodal() dlg.destroy() app.mainloop()
Comments
Post a Comment