Why doesn't changing window style flags work?

ioprst <[email protected]>
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
Why does setting the wx.TE_READONLY flag (wx.TE_PASSWORD) for the 
wx.TextCtrl window not work?

If add the wx.TE_CENTRE flag, the text is aligned after self.text.Refresh().

import wx

class Frame(wx.Frame):

    def __init__(self):
        self.readonly = False
        super().__init__(None)

        vbox = wx.BoxSizer(wx.VERTICAL)

        self.text = wx.TextCtrl(self, -1, 'My text')
        vbox.Add(self.text, 0, wx.ALL, 10)

        btn = wx.Button(self, -1, 'Set readonly')
        btn.Bind(wx.EVT_BUTTON, self.OnBtn)
        vbox.Add(btn, 0, wx.ALL, 10)

        self.SetSizer(vbox)

    def OnBtn(self, event):
        self.readonly = not self.readonly

        if self.readonly:
            self.text.SetWindowStyleFlag(wx.TE_READONLY)
            self.text.Refresh()
        else:
            pass

app = wx.App()
Frame().Show()
app.MainLoop()



-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/b81ed8a4-ab33-43f1-8d26-e93dce2dbe33%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.