Hi,
Vaclav Slavik wrote:
> I receive a created menubar in self.menuBar (that's ok), but I
> receive None if self.fileMenu?Such code would not even compile in C++, as I just found out, because
wxMenuBar doesn't have FindWindow method which is needed by
XRCCTRL(). You could run FindWindow (or XRCCTRL) on the parent frame,
but even that doesn't return the menu (probably because it is not
wxWindow).
So this is a wxWindows shortcoming. OK.
Nothing -- there was a bug (omission, really) in XRC library, it
didn't load object_refs properly when the node didn't explicitly
specify "class" property. To explain it better, this didn't work:
<object_ref name="foo" ref="bar"/>
<object name="bar" class="wxDialog">
...
while this did:
<object_ref name="foo" ref="bar" class="wxDialog"/>
<object name="bar" class="wxDialog">
...
I have fixed it in CVS now. If you don't want to update wxWindows to
post-2.3.4 version, you can workaround the bug by specifying "class"
in <object_ref>.Thanks for finding this bug!
And thank you for fixing it !
> My second question: is there any way to set window id for MenuItem
> inside a .xrc file (instead of writing ugly code such as:Yes, by setting the name property. In your example you set
the name to
"FileMenu" and the ID is assigned automatically to value returned by
calling XRCID("FileMenu"). Furthermore, if the name matches one of
wxWindows' predefined IDs, it is assigned as-is (e.g. when you have
name="wxID_NEW", the ID will be wxID_NEW).
I love the idea with predefined wxWindows' IDs (how did you find it? ;),
but this is not enough.
Consider the toolbar and the menu, and some toolbuttons do the same
actions as some menu items. Assuming I've loaded the menu first, and
stored the ID from that menu item in self.ID_DO_THE_TRICK, is there any
way to use this value in the .xrc file to create toolbutton with the
same id? Again, I understand, that I may do the trick with
wxWindow.SetId but it also not natural - is there any other way?
And the last, it's amazing that *every* quesion that is asked on this
list seems to be answered by somebody - thank you all, guys, for your
kind help!
--Victor.