import wx
class MyFrame(wx.Frame):
def init(self):
super().init(None,title=“事件处理”,size=(300,180))
panel = wx.Panel(parent=self)
self.statictext = wx.StaticText(parent=panel,label=“你是猪吗”)
b=wx.Button(parent=panel,label=‘不是’,pos=(100,50))
self.Bind(wx.EVT_BUTTON,self.on_click,b)
vbox=wx.BoxSizer(wx.VERTICAL)
vbox.Add(self.statictext,proportion=2,flag=wx.ALIGN_CENTER_HORIZONTAL|wx.FIXED_MINSIZE|wx.TOP,border=30)
vbox.Add(b,proportion=1,flag=wx.EXPAND|wx.BOTTOM,border=10)
panel.SetSizer(vbox)
def on_click(self,event):
self.statictext.SetLabelText('你是驴')
app=wx.App()
frm=MyFrame()
frm.Show()
app.MainLoop()