Can't get reference to menubar in XRC file

Hi,

I have an XRC file which contains a frame which itself contains a
menubar. I'm trying to get references to the menuitems on the menubar
but I can't get a reference to the menubar. My code:

self.res = xrc.XmlResource( 'MainFrame.xrc' )
self.mainframe = self.res.LoadFrame( None, 'MainFrame' )
self.menubar = self.res.LoadMenuBarOnFrame( self.mainframe,
"menubarMainFrame" )

the self.menubar always contains None. I also tried

self.menubar = self.res.LoadMenu( "menubarMainFrame" )

and

self.menubar = xrc.XRCCTRL( self.mainframe, "menubarMainFrame" )

None of these work.

How can I get a reference to the menubar?

Sorry, ignore my post. I just realized the answer should be:

self.menubar = self.mainframe.GetMenuBar()

···

On Mar 18, 9:47 pm, BigPilot <bigpi...@linuxmail.org> wrote:

Hi,

I have an XRC file which contains a frame which itself contains a
menubar. I'm trying to get references to the menuitems on the menubar
but I can't get a reference to the menubar. My code:

self.res = xrc.XmlResource( 'MainFrame.xrc' )
self.mainframe = self.res.LoadFrame( None, 'MainFrame' )
self.menubar = self.res.LoadMenuBarOnFrame( self.mainframe,
"menubarMainFrame" )

the self.menubar always contains None. I also tried

self.menubar = self.res.LoadMenu( "menubarMainFrame" )

and

self.menubar = xrc.XRCCTRL( self.mainframe, "menubarMainFrame" )

None of these work.

How can I get a reference to the menubar?

For the record, if you ever do want to be able to fetch menubars from XRC you just need to make it be a top level item in the XRC file.

···

On 3/18/10 1:59 PM, BigPilot wrote:

On Mar 18, 9:47 pm, BigPilot<bigpi...@linuxmail.org> wrote:

Hi,

I have an XRC file which contains a frame which itself contains a
menubar. I'm trying to get references to the menuitems on the menubar
but I can't get a reference to the menubar. My code:

self.res = xrc.XmlResource( 'MainFrame.xrc' )
self.mainframe = self.res.LoadFrame( None, 'MainFrame' )
self.menubar = self.res.LoadMenuBarOnFrame( self.mainframe,
"menubarMainFrame" )

the self.menubar always contains None. I also tried

self.menubar = self.res.LoadMenu( "menubarMainFrame" )

and

self.menubar = xrc.XRCCTRL( self.mainframe, "menubarMainFrame" )

None of these work.

How can I get a reference to the menubar?

Sorry, ignore my post. I just realized the answer should be:

self.menubar = self.mainframe.GetMenuBar()

--
Robin Dunn
Software Craftsman