XRC, wxMenuBar's, and wxMenuBarPtr's

Mark Moss moss2533 at kettering.edu
Sat Sep 6 01:09:25 EDT 2003


I have an XRC file that contains a complete menubar.  I load this
menubar into a frame with:

   self.ResMenu = wxXmlResource("menus.xrc",0)
   self.MenuBar = self.ResMenu.LoadMenuBar("MenuBarEditor")
   self.SetMenuBar(self.MenuBar)

Then set up a menu event handler:

   EVT_MENU(self, XRCID("MenuItemSnapToGrid"), self.OnSnapToGrid)

Finally, in OnSnapToGrid, I try to get a specific wxMenuItem by using
the wxMenuBar.FindItem:

   m = self.MenuBar.FindItem(XRCID("MenuItemSnapToGrid"))

This falls flat on its face because:

   AttributeError: wxMenuBarPtr instance has no attribute 'FindItem'

It seems that LoadMenuBar returns a wxMenuBarPtr rather than a
wxMenuBar.  My question then is given a wxMenuBarPtr and the ID of the
menu-item (via XRCID), how do I get ahold of the wxMenuItem object? 
Alternativly, is there a way to check/uncheck a wxMenuItem without
having a reference to the actual object (using the id or similar)?

Thanks in advance,

Mark Moss




More information about the Python-list mailing list