[wxPython-users] ColourSelect in XRC

Robin Dunn robin at alldunn.com
Mon Sep 3 19:12:01 PDT 2007


Gre7g Luterman wrote:
> What's the simplest way to put a ColourSelect object
> into a dialog that I've created with an XRC file?
> 
> If I understand correctly, XRC wants to use two-part
> construction instead of one-part construction, and
> since ColourSelect was created with one-part
> construction, it is unclear to me how to bridge the
> gap.
> 
> Any suggestions?

Take a look at PreMaskedComboBox in wx/lib/masked/combobox.py. 
Basically you need to derive a class from ColourSelect that has an 
__init__ that takes only the self parameter.  In that __init__ you need 
to create an uninitialized instance of BitmapButton, call PostCreate, 
and do any other initialization needed (see ColourSelect's __init__ for 
what the intialization steps it is doing.)  If any of those steps 
require an initialized UI object then you need to delay them until after 
the widget is fully created, such as in the first EVT_SIZE event.

Then in your XRC you can create an object of type wxBitmapButton with a 
subclass attribute of "package.module.YourClassName".

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





More information about the wxpython-users mailing list