wxPython: updating style of StaticText from event generated by button

KvS keesvanschaik at gmail.com
Wed Nov 2 00:12:26 CET 2005


Hi all,

I'm pretty new to (wx)Python so plz. don't shoot me if I've missed
something obvious ;). I have a panel inside a frame, on which a Button
and a StaticText is placed:

self.panel = wx.Panel(self,-1)
self.button = wx.Button(self.panel,-1,"Klikkerdeklik")
self.button.SetPosition((200,40))
self.Bind(wx.EVT_BUTTON, self.VeranderLabel, self.button)
self.text1 = wx.StaticText(self.panel, -1, "Dikke Henk en gekke
Greetje", size=(100,50), pos=(15,20), style=wx.RAISED_BORDER)

and via the even handler I try to give StaticText a different style:

def VeranderLabel(self, event):
  if self.text1.GetWindowStyle() == wx.SUNKEN_BORDER:
    self.text1.SetWindowStyle(wx.RAISED_BORDER)
    self.text1.Refresh()
    self.text1.Update()
  else:
    self.text1.SetWindowStyle(wx.SUNKEN_BORDER)
    self.text1.Refresh()
    self.text1.Update()

Although the style is indeed updated (checked by printing style to
console) the appearance of the StaticText stays the same. What am I
missing here?

Thanks in advance.

- Kees




More information about the Python-list mailing list