[wxPython-users] Change the wx.TE_PASSWORD style in a TextCtrl
Robin Dunn
robin at alldunn.com
Fri Jul 20 13:56:42 PDT 2007
Marco Meoni - Sbaush wrote:
> Hi all.
> 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?
SetDefaultStyle is for the text attributes, but the wx.TE_PASSWORD is a
window style flag, so you need to use SetWindowStyle. However,
depending on platform, this may be one of the styles that can not be
changed after a widget has been created, so you'll probably be better
off to just create a new instance of the widget with the desired style
and Destroy the old one. (Or use Show/Hide to switch between two that
you create at the beginning.)
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list