[wxPython-users] Enumerating XML resource names
Robin Dunn
robin at alldunn.com
Sat Jun 3 11:45:53 PDT 2006
Christian Kristukat wrote:
> Eli Golovinsky wrote:
>> You don't need to create the instances yourself unless you're using
>> Unknown widgets in your XRC.
>>
>> XRC should do that for you provided you supply the name of the derived
>> class you want to use in Subclass (right click on a widget in XRCed and
>> choose Subclass).
>
> Ok, I guess I did not express myself very well. Here's another try.
> Currently I'm successfully using xrc and I have built a complex tree with some
> subclassed nodes. Doing so, xrc is instantiating the subclassed controls
> automatically when the xrc tree is loaded. Now, reading about your recent
> developments of pywxrc I wanted to give it a try. Pywxrc is creating a class for
> every subclassed node in the tree. Robin already explained me that the xrc tree
> is loaded when I create an instance of the toplevel frame class (or every other
> I guess). But how about any other subclassed node somewhere down the tree? I
> can't imagine how it will be added to the gui just by instantiating such a class.
XRC will load the contents of the Frame or Panel just like before. If
you have items that use the subclass attribute or custom handlers, they
will work exactly the same way. All pywxrc does (so far) in addition to
standard XRC is that it creates a window class that uses XRC to load
widgets onto itself and adds "self.name = XRCCTRL(self, 'name')" lines
for creating references to the items loaded from XRC so you don't have
to look them up every time you need them.
Why don't you give it a try and see how it works for you? If there is
something that it prevents you from doing that you are doing already I'm
sure Eli would be interested in learning about it. Here is a download
link for the current revision in CVS:
http://cvs.wxwidgets.org/viewcvs.cgi/*checkout*/wxWidgets/wxPython/wx/tools/pywxrc.py?rev=1.6
If you want to also try the modifications in XRCed that integrate with
pywxrc then you can get those files as well from here:
http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/tools/XRCed/
BTW, I just thought of one thing that pywxrc currently won't handle
properly and that is if you use the subclass attribute on the top-level
item in the XRC. This is because the generated code uses the
xrc.XmlResource.LoadOn* methods to load the contents onto an existing
instance of a plain Frame (or Panel, Dialog, etc.) But since the
generated code is meant to be derived from it is probably easier to do
your customization of the Frame in a derived class than to make a custom
class that XRC can load directly, so I don't think it is much of a loss.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list