[wxPython-users] how to automate menu generation ?

Christopher Barker Chris.Barker at noaa.gov
Wed Nov 7 11:58:35 PST 2007


jonhattan wrote:
>>        self.Bind(wx.EVT_MENU, func, item[1])
> last line is wrong. correct is :

are you sure?

>       self.Bind(wx.EVT_MENU, func, menu_item.GetId())
> 
> or
>       self.Bind(wx.EVT_MENU, func, getattr(self, menuid))

self.Bind(wx.EVT_MENU, func, menu_item)

should work. If you pass in an item for the 3rd argument instead of an 
ID, it should pull the id from it.

The nice thing about all that is that you don't need to worry about IDs 
at all - just store a reference to the menu item itself in a dict or 
somewhere, and use that.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list