[wxPython-users] Change the wx.TE_PASSWORD style in a TextCtrl
Marco Meoni - Sbaush
sbaush at gmail.com
Mon Jul 23 03:46:33 PDT 2007
i solved with this code:
if "condition":
self.value.SetWindowStyle(wx.NORMAL)
else: self.value.SetWindowStyle(wx.TE_PASSWORD)
On Linux it works perfectly, but on Windows this doesn't work... It's
normal?
Can i write my code better?
Thanks.
Marco.
On 7/20/07, Robin Dunn <robin at alldunn.com> wrote:
>
> Marco Meoni - Sbaush wrote:
> > Hi all.
> > I have a wx.TextCtrl like this
> >
> > self.value =3D wx.TextCtrl(self.myPanel, -1, "",style=3Dwx.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!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-- =
Marco Meoni (Sbaush)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200707=
23/ea9044a2/attachment.htm
More information about the wxpython-users
mailing list