In the wxGlade dialog for editing menu items there is an “id” field for items. I had left it blank and I believe that’s why each item had an id of “-1” (I think this prompts the code to auto-assign some id to these objects). On the guess that this “id” field might actually name that menu choice (i.e. you might have a button called enable_ssl_button that kicks off a function called enable_ssl), I entered an id (“close_cw_menu_item”) for the close_cw menu item. Then when I generate code, running it returns a squawk "NameError: global name ‘close_cw_menu_item’ is not defined…
···
---------- Forwarded message ----------
From: Christopher Barker Chris.Barker@noaa.govTo: wxpython-users@lists.wxwidgets.org
Date: Wed, 07 May 2008 11:58:44 -0700
Subject: Re: [wxpython-users] Newbie question re:wxMenuBar events
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%20GuideI really don’t like IDs. I do wish you could just do:
Menu_Item.Bind(…)
But such is life.
-Chris
–
Christopher Barker, Ph.D.
OceanographerEmergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 faxSeattle, WA 98115 (206) 526-6317 main reception
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users