[wxPython-users] Enumerating XML resource names

Christian Kristukat ckkart at hoc.net
Fri Jun 2 16:28:40 PDT 2006


Robin Dunn wrote:
> Christian Kristukat wrote:
>> Eli Golovinsky wrote:
>>> If you get the latest pywxrc and XRCed from CVS, you'll be able to use
>>> the code generation features there.
>>>
>>> For each dialog a class is created that contains an attribute for each
>>> widget in the dialog.
>>>
>>>
>>> You can find the links to the CVS repository in previous posts or on the
>>> wxPython site.
>>>
>>>
>>> If you need some more help, let me know.
>>
>> I'm a bit confused what to do with the generated code. With the old
>> approach, I
>> load the top level frame which is defined in the xrc file and xrc
>> cares about
>> the instantiation and creation of subclassed nodes in the xrc tree.
>> Now, am I
>> supposed to subclass the pywxrc generated classes?
> 
> Yes.  Of course the old approach still works too, pywxrc is just trying
> to make it easier to use XRC without requiring you to know the necessary
> tricks that make it work.
> 
>> How do I finally load the gui
>> from the xrc resource?
> 
> It is done for you when you call the __init__ method of the base class.
>  For example, here is a module I made for a sample app I used to try and
> reproduce a bug:
> 
> 
> import wx
> from cbscroll_xrc import xrcFRAME
> 
> class FRAME(xrcFRAME):
>     def __init__(self):
>         xrcFRAME.__init__(self, None)
>         self.SPanel.SetVirtualSize(
>             self.SPanel.GetSizer().GetMinSize())
>         self.SPanel.SetScrollRate(20,20)
> 
> app = wx.App(False)
> frm = FRAME()
> frm.Show()
> app.MainLoop()
> 
> 
> All of the XRC specific things are in the cbscroll_xrc module and all I
> have to do is derive from xrcFRAME and use it normally.  The self.SPanel
> member was initialized in xrcFRAME.__init__ for me.

I see, thanks for explaining. However, I have further subclassed nodes below top
level in the xrc tree. How about them? If I created an instance myself, I would
have to add it to the gui myself, or am I wrong?

Regards, Christian




More information about the wxpython-users mailing list