|We don't bite newbies here... much|
Using Wx with elements from XRC (XML resources)by tsee (Curate)
|on Nov 01, 2006 at 12:40 UTC||Need Help??|
tsee has asked for the
wisdom of the Perl Monks concerning the following question:
Dear fellow monks,
Everyone who has ever written GUI applications knows that designing them in code can be a pain. Fortunately, using Wx.pm / wxWidgets (and some other GUI toolkits), it's possible to load the design of your GUI from an XML file which you previously generated using a GUI designer such as wxglade.
Sadly, the documentation for this procedure is lacking from the Wx Perl docs altogether and doesn't seem to be overly verbose in, say, the Python Wx documentation either. But I'm digressing!
I created a custom Wx Panel using wxglade which contains just one button for demonstration purposes and exported the results into, say, t.xrc.
Since I want my panel to behave a little different from the default Wx::Panel, I specified that its class is 'MyPanel' in the wxglade editor. After all, support for this kind of thing (subclassing) is a central point of the Wx OO interface. In my Perl code, I implement the MyPanel package as a subclass of Wx::Panel as required.
Running the script, I see the main window with my custom panel (and button) as expected, but I also get an error message in a dialog box: Subclass 'MyPanel' not found for resource 'panel_1', not subclassing!. The only exact mention I found of this was in the sources of wxWidgets itself. That was way too C++y for me, though.
The wxPython docs mention something about a necessity to map the (Perl or Python) class name to the class name as XRC sees it. Finally, I found some mention of a similar problem in the wxperl mailing list: original post, first answer, second answer. Basically, this feature was missing from Wx before 0.16. Mattia promised to add it in 0.16 and judging from the ChangeLog, he did. Still, I'm not having any success with the most recent Wx. I cannot find any documentation either.
What am I doing wrong? Any Insights?
Thanks for reading,