XRC and dynamically created widgets?
John Salerno
johnjsal at NOSPAMgmail.com
Mon Oct 2 12:48:27 PDT 2006
Robin Dunn wrote:
> John Salerno wrote:
>> John Salerno wrote:
>>
>>> Ah, I forgot to add the Notebook to a BoxSizer! Now it works! :)
>>
>> Ok, more confusion. Here is my code and XRC. Why do I get this error
>> message when I don't comment out the two lines in the InitMenu()
>> method, but when they are commented it works fine (and still shows the
>> menu bar)?
>>
>> Python Error
>> XRC resource 'menuBar' (class 'wxMenuBar') not found!
>
> Because the menu bar is not a top-level item in your XRC file. It is a
> child of the mainFrame so it is created and associated with the frame
> when the frame is loaded. The Load* methods can only "see" items that
> are at the top-level in the resource, in other words their parent node
> is <resource>
>
Ah ha! Thanks! So which is the preferred method? I think I put the
MenuBar beneath the Frame because that's how it's normally done when
hand-written, right? The menu is a child of the frame? Seems simpler to
do that in XRC too, so the frame automatically initializes it, but I see
an example that doesn't do this (which is where I got the InitMenu code
from).
Thanks.
More information about the wxpython-users
mailing list