[wxPython-users] Change the wx.TE_PASSWORD style in a TextCtrl
Ed Leafe
ed at leafe.com
Fri Jul 20 13:29:01 PDT 2007
On Jul 20, 2007, at 3:27 PM, Marco Meoni - Sbaush wrote:
> I have a wx.TextCtrl like this
>
> self.value = wx.TextCtrl(self.myPanel, -1, "",style=wx.TE_PASSWORD)
>
> I would create a simple button that shows/hides the password.
>
> i wrote this function but that doesn't works...
>
> def OnShowHide(self,event):
> self.value.SetDefaultStyle(wx.NORMAL)
>
> Have you an idea? How can i show the password in readble style
> clicking on this button, and return to password-style reclicking?
You can't do that with a single control. One approach would be to
create both a password and non-password textbox, and add them both to
a box sizer. Initially set the sizer to show the password control,
and hide the plain one. Then your button's event handler would
determine the shown control, copy its value to the hidden one, and
then reverse the visibility of both.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
More information about the wxpython-users
mailing list