我看过 another question关于这个话题,但我无法完全获得对我有用的信息,所以我想我会给出我的细节——我怀疑我只是目光短浅。
我正在尝试从测试框架中练习我的 GUI,这涉及在测试脚本中手动调用事件(在本例中为按下按钮)。到目前为止,除了其他不相关的废话,我还有:
# In GUI class:
self.button_1 = wx.Button(self, id=wx.ID_ANY, label="Button 1")
self.button_1.Bind(wx.EVT_BUTTON, self.button_1)
# In GUI Test class:
event = wx.PyCommandEvent(X, Y)
wx.PostEvent(get_gui_instance(), event)
我的问题是我不知道 X
和 Y
应该是什么(假设其余的没问题)。非常感谢任何帮助。
btnInfo = wx.Button(self,-1,"Some Button")
evt = wx.PyCommandEvent(wx.EVT_BUTTON.typeId,btnInfo.GetId())
wx.PostEvent(self, evt) #attach event to self ... alternatively maybe attach to btnInfo
应该可以
我是一名优秀的程序员,十分优秀!