gpt4 book ai didi

python - 以编程方式调用 wxPython EVT_BUTTON 事件

转载 作者:太空宇宙 更新时间:2023-11-03 13:49:20 26 4
gpt4 key购买 nike

我看过 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)

我的问题是我不知道 XY 应该是什么(假设其余的没问题)。非常感谢任何帮助。

最佳答案

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

应该可以

关于python - 以编程方式调用 wxPython EVT_BUTTON 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12786471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com