[wxpython-users] Newbie question re:wxMenuBar events

Christopher Barker Chris.Barker at noaa.gov
Wed May 7 11:58:44 PDT 2008


Gre7g Luterman wrote:
> if I were writing this code by hand, each item would look 
> more like:
>  
> ID_BUY = wx.NewId()
> wxglade_tmp_menu.Append(ID_BUY, "Buy CW", "", wx.ITEM_NORMAL)
> self.Bind(wx.EVT_MENU, self.buy_license, id=ID_BUY)

I'd do:

item = wxglade_tmp_menu.Append(wx.ID_ANY, "Buy CW", "", wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self.buy_license, item)

see:
http://wiki.wxpython.org/wxPython%20Style%20Guide

I really don't like IDs. I do wish you could just do:

Menu_Item.Bind(...)

But such is life.

-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