我想用AddPendingEvent
发送事件。但是,在调用AddPendingEvent
之后什么也不会发生。下面是一个示例,其中一个按钮将向帧发送wx.CloseEvent
。你知道吗
import wx
class MainFrame(wx.Frame):
def __init__(self):
super(wx.Frame, self).__init__(None, wx.ID_ANY, 'Test')
self.button = wx.Button(self, wx.ID_ANY, 'Close', self.GetClientSize()/2)
self.button.Bind(wx.EVT_BUTTON, self.OnButton)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Show()
def OnButton(self, event: wx.CommandEvent):
self.AddPendingEvent(wx.CloseEvent())
def OnClose(self, event: wx.CloseEvent):
self.Destroy()
if __name__ == '__main__':
app = wx.App()
frame = MainFrame()
app.MainLoop()
我也试过QueueEvent
或wx.PostEvent
,结果是一样的。你知道吗
您应该按
PyCommandEvent
创建一个类型为wx.EVT\u关闭例如:相关问题 更多 >
编程相关推荐