[wxPython-users] Re: XRCed: Most simple example won't work,
what am I doing wrong?
Roman Rolinsky
rolinsky at femagsoft.com
Thu May 10 07:33:25 PDT 2007
On Thu, 2007-05-10 at 15:17 +0200, Markus Schöpflin wrote:
> Roman Rolinsky wrote:
>
> > Hi,
> >
> > It's a bug in pywrc tool - it does not support a MenuBar inside a
> > top-level window (actually it supposes all window children can be found
> > by FindItemById from the main objct which is not the case for menu
> > classes).
> >
> > self.MENU_FILE = xrc.XRCCTRL(self, "MENU_FILE")
> > self.COMMAND_QUIT = self.FindItemById(xrc.XRCID("COMMAND_QUIT"))
> >
> > it sould have generated something like
> >
> > self.MENU_FILE = self.GetMenuBar()
> > self.COMMAND_QUIT = self.MENU_FILE.FindItemById(xrc.XRCID("COMMAND_QUIT"))
> >
> > GetMenuBar is needed because XRCCTRL can't find the menubar object
> > (maybe because it's not really a control). Actually the name MENU_FILE
> > in the XRC file is probably ignored colpletely.
>
> Is there some workaround I can employ, apart from manually editing the generated sources?
You can put the MenuBar on the top level, then call
your_frame_object.SetMenuBar(xrcMENU_BAR()).
BTW, it's better to give standard names to the menu items, like
wxID_EXIT, then you'll have icons attached to them automatically and
instead of XRCID("COMMAND_QUIT") can use a predefined constant
wx.ID_EXIT.
>
> > pywrc is a separate tool which is called by XRCed, and provides only
> > basic code generaion, which can be often used as a starting point for a
> > project but sometimes requires hand-editing. I'm working on a general
> > way to provide code-generation from XRCed in the future version.
>
> Thanks for the clarification.
>
> Markus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
More information about the wxpython-users
mailing list