wxSimpleHtmlListBox from xrc

Hi all!

Python 2.7 32 bit, wxPython 2.8.11.0 (msw-unicode) 32 bit, Win 7 64bit

I am loading a dialog containing wx.SimpleHtmlListBox from xrc. Here is
the entry:

<object class="wxSimpleHtmlListBox" name="ID_LB_JOBS">
  <style>wxHLB_DEFAULT_STYLE</style>
</object>

In my python code, I assign a reference to the control to a member
variable like this:

self.LbJobs = xrc.XRCCTRL(self, "ID_LB_JOBS")

There is no other object named "ID_LB_JOBS" in my xrc file.

When, a few lines later, without having touched self.LbJobs, I am trying
to populate it, I get the following error:

    self.LbJobs.Append(html)
AttributeError: 'HtmlListBox' object has no attribute 'Append'

Somehow, the XRCCTRL function returned a wx.HtmlListBox object instead
of a wx.SimpleHtmlListBox.

Is it a bug or I am doing something completely wrong?

Is there a way to "typecast" the self.LbKobs variable to
wx.SimpleHtmlListBox, provided that it has been correctly instantiated
as a wx.SimpleHtmlListBox by its XRC handler?

Thank you very much for your replies!

Regards,

Stavros

XRC uses some class information classes (aka wxRTTI) to help it to be able to dynamically construct instances of specific classes at runtime. wxPython also uses that information when it is determining what type of proxy class to instantiate when wrapping a pointer to a base class. It looks like part of that information is not present for wxSimpleHtmlListBox and so either XRC or wxPython went up to the parent class instead.

This will be fixed in the next 2.9 release. In the meantime you can use the unknown control mechanism in XRC. The way it works is you create an item in the XRC with class="unknown" and then in the Python code after you've loaded the parent frame or panel or whatever you create the instance of the wx.SimpleHtmlListBox and use the XmlResource object's AttachUnknownControl method to put it into the right place in the layout.

···

On 1/8/11 9:55 AM, Tsolakos Stavros wrote:

Somehow, the XRCCTRL function returned a wx.HtmlListBox object instead
of a wx.SimpleHtmlListBox.

Is it a bug or I am doing something completely wrong?

--
Robin Dunn
Software Craftsman

Hi Robin.

Thank you for your reply!

This will be fixed in the next 2.9 release. In the meantime you can use
the unknown control mechanism in XRC. The way it works is you create an
item in the XRC with class="unknown" and then in the Python code after
you've loaded the parent frame or panel or whatever you create the
instance of the wx.SimpleHtmlListBox and use the XmlResource object's
AttachUnknownControl method to put it into the right place in the layout.

This is what I love in OSS and wxPython in particular. The C++ wxWidgets
xml handler looked ok, so I thought that either I had done something
wrong in my code or there is a very python blending specific bug.

In the meantime, I have used some wxPython magic and created the control
using code, just like during the pre-XRC days.

wxPython rocks! Plain and simple!

Thanks again,

Stavros