我有两个这样的课程:
class ClassNrOne(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Title',size=(1024,600))
self.panel = wx.Panel(self,size=(1024,600))
self.mybutton = wx.Button(self.panel,label="OK",pos=(215,160),size=(80,40))
self.Bind(wx.EVT_BUTTON, ClassNrTwo.do, self.mybutton)
class ClassNrTwo(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self, parent,id)
self.newpanel = wx.Panel(self,size=(1024,600))
def do(self,event):
# do something
当我尝试运行它时,我收到错误消息:“'ClassNrOne' 对象没有属性 'ClassNrTwo'”。如果我向后尝试-> self.Bind(wx.EVT_BUTTON, do.ClassNrTwo, self.mybutton) 我收到消息:“未定义全局名称'do'”。如何从另一个班级调用事件?
与此相关的第二个问题:单击“mybutton”时是否也可以从 ClassNrTwo 调用“__init__”?
编辑:我只是将我所有的小问题合并为一个大问题:https ://stackoverflow.com/questions/12604139/need-tutorial-for-menubar-handling-panel-building