Reputation: 1194
I Have a subclass of wx.Frame
in which I have constructed a fully functioning editor with a menu and multiline text input. I next need to create a checkbox menu item inside a menu created with this code:
self.menuBar = wx.MenuBar()
self.menuBar.Append(self.viewMenu, "&View")
self.SetMenuBar(self.menuBar)
Using this code:
self.HideToolbarMenuItem = self.viewMenu.Append(wx.ID_ANY, "Hide Toolbar", self.HideToolbarHelp, kind=wx.ITEM_CHECK)
How do I add event handling to it or get it's value (True
or False
)? I am not interested yet in how to hide the toolbar.
EDIT: The menu does show the checkbox, and it can be selected
Upvotes: 0
Views: 1619
Reputation: 1194
Use self.HideToolbarMenuItem.IsChecked()
and a normal event handler. Example:
def OnBoxChecked(self, event):
if self.HideToolbarMenuItem.IsChecked():
self.statusbar.SetStatusText('Checked')
else:
self.statusbar.SetStatusText('Not Checked')
Upvotes: 1