如何在wxPython中获取事件的详细信息
我有一段代码返回滑块生成的事件。
我使用 self.Bind(wx.EVT_SCROLL,self.OnSlide) 绑定事件。
处理该事件的代码如下所示:
def OnSlide(self,event):
widget = event.GetEventObject()
这很好,但每次执行代码时都会抛出错误。它显示:
AttributeError: 'PyEventBinder' object has no attribute 'GetEventObject'
我希望能够查看哪个滑块生成了该事件,但每次我尝试查找时都会出现错误。
如何才能让代码正确执行呢?
非常感谢。
I have a section of code which returns events generated by a slider.
I bind the event with self.Bind(wx.EVT_SCROLL,self.OnSlide)
.
The code which handles the event reads something like:
def OnSlide(self,event):
widget = event.GetEventObject()
This is great but an error gets thrown every time the code is executed. It reads:
AttributeError: 'PyEventBinder' object has no attribute 'GetEventObject'
I want to be able to see which of the sliders generated the event but the error appears every time I attempt to find out.
How can I get the code to execute correctly?
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要调试类似的内容,请将以下内容作为事件处理程序中的第一个语句:
这将在此时停止程序的执行并为您提供交互式提示。然后,您可以发出以下命令来找出可用的方法:
当我第一次学习 wxPython 时,我发现这种技术非常宝贵。
To debug something like this, put the following as the first statement in your event handler:
This will stop the execution of the program at this point and give you an interactive prompt. You can then issue the following command to find out what methods are available:
When I was first learning wxPython I found this technique invaluable.
以下内容适用于 Windows 7、wxPython 2.8.10.1、Python 2.5
The following works for me on Windows 7, wxPython 2.8.10.1, Python 2.5