I'm learning wx and I've got a problem like this: let's say I create few StaticText objects and then I want to change its labels on some events. example:
import wx
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent=parent)
self.panel=wx.Panel(self)
for i in range(5):
self.button=wx.Button(self.panel, -1, label='b'+str(i), pos=(20,30*i))
self.button.Bind(wx.EVT_BUTTON, self.on_button)
self.label=wx.StaticText(self.panel, -1, label='label'+str(i), pos=(120,30*i), name='label'+str(i))
def on_button(self, event):
b=event.GetEventObject().GetLabel()
if b.endswith('1'):
self.label1.SetLabel('sss')
x=wx.App()
y=MyFrame(None).Show()
x.MainLoop()
so, as you can see I want to change label of self.label1 I've created earlier, and I can't do that because of an error: in on_button; AttributeError: 'MyFrame' object has no attribute 'label1'
I think I have to change something while creating objects but I don't know what.