Hi Robin,
Frank Niessink wrote:
> Also, what would the best work-around be?I don't know. Have you tried getting the checked state from the menu?
Below is what I ended up doing. doCommand is called when the user
invokes the checkable menu item. The work-around is a bit complicated
because the menu item is both part of a regular menu and part of a
(column header) popup menu.
def doCommand(self, event):
# There's a bug in wxPython 2.8.3 on Windows XP that causes
# event.IsChecked() to return the wrong value in the context menu.
# The menu on the main window works fine. So we first try to access the
# menu to get the checked state from the menu item itself.
# This will fail if the event is coming from the window, but in that
# case we can expect event.IsChecked() to work so we use that.
try:
isChecked =
event.GetEventObject().FindItemById(event.GetId()).IsChecked()
except AttributeError:
isChecked = event.IsChecked()
self.settings.set(self.section, self.setting, str(isChecked))
Cheers, Frank
···
2007/3/30, Robin Dunn <robin@alldunn.com>: