【发布时间】:2014-09-24 05:16:45
【问题描述】:
很抱歉,如果这很简单,但我正在尝试使用 wxPython 将事件绑定到菜单栏中的复选框。由于某种原因,它不会工作!我尝试了各种不同的方法来让它打印一份声明,但是当我选中该框时没有任何反应。它没有正确绑定吗?这只是我为演示问题而编写的一个简单应用程序...
import wx
class Frame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self)
menuBar = wx.MenuBar()
menu = wx.Menu()
self.checkbox = menu.AppendCheckItem(-1, "Check me")
menuBar.Append(menu,'&check box')
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_CHECKBOX, self.onCheck, self.checkbox)
def onCheck(self, e):
print self.checkbox.IsChecked()
app = wx.App()
test = Frame(None, -1, "Test")
test.Show()
app.MainLoop()
【问题讨论】:
标签: events checkbox binding wxpython