我有一个框架,一旦用户点击退出按钮,我想打开一个对话框,问他是否真的想关闭窗口。在
所以我做了:
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
然后我回电话:
^{pr2}$但是,我得到了一个错误:
TypeError: unbound method Veto() must be called with CloseEvent instance as first argument (got bool instance instead)
如何捕获引发的事件的closeWindows实例?在
您想调用
event.Veto(True)
,而不是wx.CloseEvent.Veto(True)
。event
是wx.CloseEvent
的一个实例,这就是您想要的Veto
。现在您正试图对wx.CloseEvent
类本身调用Veto
,这是没有意义的。在你不需要做那么多。如果捕获事件并且不调用
event.Skip()
,则它不会向前传播。因此,如果您捕获事件并且不调用event.Skip()
或self.Destroy()
,那么窗口将保持打开状态。在相关问题 更多 >
编程相关推荐