Adding Custom Widgets to wxGlade

wxGlade has the ability to integrate custom or 3rd party widgets into its pallette. This feature is not documented very well. By using some sample code from Alberto Griggio and digging through the core-widgets source code, I was able to create bridge code that adds Andrea Gavana’s FloatSpin control to the pallette. For those that follow, I suggest starting with the a similar class from the core pallette and the code for html_window. The only real gotcha for this integration was that the widget container was not seeing KILL FOCUS events from the FloatSpin controls and therefore changed data was not saved. This was fixed by trapping EV_FLOATSPIN events and calling the update.

wxGlade Pallette with Float Spin

The FloatSpin bridge code is installed by untarring from within your .wxglade directory. The included README contains more details.

Edits:
11/16/2006 – uploaded version 1.1. Adds event handlers and support for digits=0.

This entry was posted in Python, wxPython. Bookmark the permalink.

5 Responses to Adding Custom Widgets to wxGlade

  1. Max P says:

    Hello Kevin,

    Well done,really good work!
    Is there any tutorial where is explain how to write a costumer widget for the wxGalde?
    Is there a place where I can upload my own wxGlade-widget or get other widget for the wxGlade?

    Thanks allot

    Max P

  2. kpd says:

    Thanks Max. I’m not aware of anything specific, I figured it out by stepping through the code and copying others. Best I can offer is to start here: http://wxglade.sourceforge.net/tutorial.php and maybe add your code or a link to it. If that doesn’t work I would post it here for you, but I think the sourceforge site would be the first chouse.

  3. I want to use wxGlade to build custom widgets for the wxGlade custom widget pallet – a recursive use of wxGlade. The custom widgets are simply sizers with widgets from the pallet inside. Similar to what drawing packages call “grouping”. The properties of the new widget are those of the containing sizer and it’s widgets. Nothing new is being added.

    wxPython addressing of same would look like TheFrame.CustomWidgetInstanceA.sizerA.CustomWidgetInstanceB.sizerB.CustomWigetInstanceC … until we drill down to a real widget’s property. Same is true for events & binding.

    I’ve looked at “floatspin” & way to much. The custom widgets I envision have no new properties. They inherit all their properties from the included widgets.

    Another way to look at this is as a wxGlade macro. Grouping existing capabilities into a sizer package that can be used over and over.

    Where to look & read?

  4. kpd says:

    I like it. Not sure where to find the info other than stepping through the source code.

  5. werner says:

    Nice job, wish there would be more.

    Some questions:
    - why do you keep floatspin in wxglade/widgets and use an import “from FloatSpin”

    Should the import be

    import wx.lib.agw.FloatSpin as FloatSpin

    or similar, i.e. get the actual widget from the wxPython library in use.

    I played around with the code and I think I did the necessary changes but not tested a lot, especially as I not very familar with wxGlade.

    Could I send the code to you?

    Werner

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>