Problems loading panel from XRC

Hi guys,

Using DialogBlocks 2005 - v3.10 I exported XRC and I am loading this
with the following code:

class WikEdFrame(wx.Frame):
    def __init__(self, parent):
        """ Constructor of the main frame """
        wx.Frame.__init__(self, parent, -1, "WikEd v1.0", size=(400,200),
                          style=wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)

        ## invoke window from XRC
        res = xrc.XmlResource("wiked.xrc")
        panel = res.LoadPanel(self, "ID_WIKEDMAIN")

It works, but I get errors. The following errors are thrown at me but
the panel is succesfully loaded. Does anybody know why this happens?

20:09:25: Subclass 'WikedMain' not found for resource 'ID_WIKEDMAIN',
not subclassing!
20:09:25: Unknown style flag wxHSCROLL
20:09:25: Unknown style flag wxVSCROLL

The first error puzzles me. Is the XRC code wrong that DialogBlocks
produces? The second and third ones are probably new in wxWidgets
newer then the ones used by wxPython?

The first error comes from this line;

<object class="wxPanel" name="ID_WIKEDMAIN" subclass="WikedMain">

I do not know why the subclass line is there. Any ideas?

With regards,
- Jorgen

Jorgen Bodde wrote:
[...]

It works, but I get errors. The following errors are thrown at me but
the panel is succesfully loaded. Does anybody know why this happens?

20:09:25: Subclass 'WikedMain' not found for resource 'ID_WIKEDMAIN',
not subclassing!
20:09:25: Unknown style flag wxHSCROLL
20:09:25: Unknown style flag wxVSCROLL

The first error puzzles me. Is the XRC code wrong that DialogBlocks
produces?

No, see below.

The second and third ones are probably new in wxWidgets
newer then the ones used by wxPython?

Probably. Since 3.10 was just barely released I expect that Julian is using wx 2.7 to build it. You can try with a 2.7 preview build of wxPython if you want. See the wxPython-dev mail list and http://starship.python.net/crew/robind/wxPython/daily/

The first error comes from this line;

<object class="wxPanel" name="ID_WIKEDMAIN" subclass="WikedMain">

I do not know why the subclass line is there. Any ideas?

Because you specified a class name in DialogBlocks (or perhaps it automatically did it.) The subclass attribute is used by XRC to create the instance using a pluggable subclass factory instead of creating the class using the standard class in the class attribute. In C++ the subclass factory can instantiate any class that uses the wxRTTI macros, but since your C++ binary (wxPython) doesn't have a class named WikedMain it is giving you the error. So you probably just need to remove the class name attribute from DialogBlocks and then save the XRC again.

BTW, there is a subclass factory loaded for Python classes too, but it requires that you specify the package/module name in front of the class name so the factory knows what to import to be able to find the class. See the demo for an example.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Thanks again for the quick reply! I contacted Julian too and he suggested to rename the custom class back to wxPanel in DialogBlocks to solve the subclass problem. The missing tags that are not found are most likely indeed the cause of a newer wxWidgets. I will try te preview build I was not aware there was a wx2.7.0 build already

The subclass idea is nice though, it makes it even more dynamic. I will look into that!

Thanks,

  • Jorgen
···

On 9/26/06, Robin Dunn robin@alldunn.com wrote:

Jorgen Bodde wrote:
[…]

It works, but I get errors. The following errors are thrown at me but
the panel is succesfully loaded. Does anybody know why this happens?

20:09:25: Subclass ‘WikedMain’ not found for resource ‘ID_WIKEDMAIN’,

not subclassing!
20:09:25: Unknown style flag wxHSCROLL
20:09:25: Unknown style flag wxVSCROLL

The first error puzzles me. Is the XRC code wrong that DialogBlocks
produces?

No, see below.

The second and third ones are probably new in wxWidgets
newer then the ones used by wxPython?

Probably. Since 3.10 was just barely released I expect that Julian is
using wx 2.7 to build it. You can try with a 2.7 preview build of
wxPython if you want. See the wxPython-dev mail list and
http://starship.python.net/crew/robind/wxPython/daily/

The first error comes from this line;

I do not know why the subclass line is there. Any ideas?

Because you specified a class name in DialogBlocks (or perhaps it
automatically did it.) The subclass attribute is used by XRC to create
the instance using a pluggable subclass factory instead of creating the

class using the standard class in the class attribute. In C++ the
subclass factory can instantiate any class that uses the wxRTTI macros,
but since your C++ binary (wxPython) doesn’t have a class named
WikedMain it is giving you the error. So you probably just need to

remove the class name attribute from DialogBlocks and then save the XRC
again.

BTW, there is a subclass factory loaded for Python classes too, but it
requires that you specify the package/module name in front of the class

name so the factory knows what to import to be able to find the class.
See the demo for an example.


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org