每当您按下按钮时,我希望能够从下面示例中的其他两个函数中调用我的第三个函数。如何在保持 s 值的同时做到这一点?
import wx
class MyDialog(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(350, 100))
wx.Button(self, 1, '1', (100, 10))
wx.Button(self, 2, '2', (185, 10))
self.Bind(wx.EVT_BUTTON, self.one, id=1)
self.Bind(wx.EVT_BUTTON, self.two, id=2)
def one(self,event):
s=1
def two(self,event):
s=2
def three(self,event):
print s
class MyApp(wx.App):
def OnInit(self):
dlg = MyDialog(None, -1, 'Example')
dlg.Show(True)
dlg.Centre()
return True
app = MyApp(0)
app.MainLoop()