Question about getting name of checked item

Alec Bennett whatyoulookin at yahoo.com
Tue Nov 20 13:57:38 PST 2007


I need to find the name of a checked item in a menubar
and was wondering the best way to do it. 

Perhaps there's a method I can perform on the event
that will give me the name?

For example:

cityMenu = wx.Menu()
cityMenu.Append(101, "Los Angeles",
kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_TOOL, self.OnCityCheck, id=101)

def OnCityCheck(self, event):
...theobject = event.GetEventObject()
...print theobject .GetLabel() 

This, however, prints the label of my frame, not the
menu item.

Is there some way to print either the label or the ID#
of the menu item checked above?

Or maybe there's some way to send my OnCityCheck a
paramter? Something like:

self.Bind(wx.EVT_TOOL, self.OnCityCheck("a paramter"),
id=101)

Thanks for any help.






      ____________________________________________________________________________________
Be a better pen pal. 
Text or chat with friends inside Yahoo! Mail. See how.  http://overview.mail.yahoo.com/




More information about the wxpython-users mailing list