Events wxPython中的复选框事件不工作
如果这太简单,我很抱歉,但我正在尝试使用wxPython将事件绑定到菜单栏中的复选框。由于某种原因,它不会起作用!我尝试了多种不同的方法让它打印一条语句,但当我选中该复选框时,什么也没有发生。它是否绑定不正确?这只是我写的一个简单的应用程序来演示这个问题Events wxPython中的复选框事件不工作,events,checkbox,binding,wxpython,Events,Checkbox,Binding,Wxpython,如果这太简单,我很抱歉,但我正在尝试使用wxPython将事件绑定到菜单栏中的复选框。由于某种原因,它不会起作用!我尝试了多种不同的方法让它打印一条语句,但当我选中该复选框时,什么也没有发生。它是否绑定不正确?这只是我写的一个简单的应用程序来演示这个问题 import wx class Frame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, t
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()
我已经弄明白了。我需要将绑定事件从
wx.EVT_复选框
更改为wx.EVT_菜单