用wxpython编写界面用button调用另一个类中的事件,如何编程?

class InsertFrame(wx.Frame):
......
self.Bind(wx.EVT_BUTTON, self.OnTest, button2)
......
def OnTest(self, event):
test = Test()
test.setToken("****", "****")
self.screen_name = label.screen_name.GetValue()
test.user_timeline(self.screen_name)
for i in range[0:200]:
self.tc.AppendText(test.temp[i])

class Test(unittest.TestCase):
......

user_timeline是在Test中的一个方法,需要在第一个类中调用,如何修改程序?

不知道理解的对不对。你看这样行么。

class Test(unittest.TestCase):
......

无缩进t = Test(‘test1’,'test2')

class InsertFrame(wx.Frame):
......
self.Bind(wx.EVT_BUTTON, self.OnTest, button2)
......
def OnTest(self, event):
test = Test()
test.setToken("****", "****")
self.screen_name = label.screen_name.GetValue()

直接用实例化后的t.user_timeline
t.user_timeline(self.screen_name)

for i in range[0:200]:
self.tc.AppendText(test.temp[i])
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-07-19
你是说A类中触发Test这个类的一个事件吧,翻一下自定义事件,看看触发事件那句话咋个写来着就好了
相似回答