[wxPython-users] [ANN] PlateButton Control for wxPython

Robin Dunn robin at alldunn.com
Fri Dec 14 21:05:22 PST 2007


Jorgen Bodde wrote:
> Robin,
> 
> This is more  a question to you. Is there like a standard "template"
> for creating such a custom control? A lot of these pitfalls could be
> omitted if there is let's say a best in class example of how the
> custom control (derived from wx.PyControl) could work with most
> methods filled in or at leasty documented that they need to be filled
> in.

I gave this list in one of my OSCON talks, I think it is still mostly 
accurate:

1. Derive from wx.PyControl. This enables reflection of some pertinent
C++ virtual methods to Python methods in the derived class.

2. Call SetInitialSize from the __init__ method, passing the size
passed to __init__. This helps set things up properly for sizers, and
also sets the size of the control appropriately (using either the size 
given or the best size.)

3. Call InheritAttributes from the __init__ method. If the parent has
non-standard font or colors then it will set them for your control.

4. Implement a DoGetBestSize method, returning the wx.Size that would
best fit your control based on current font, label or other content, etc.

5. Implement an AcceptsFocus method, returning True if the control is
meant to receive the keyboard focus.


http://wxpython.org/OSCON2004/advanced/wxPython-Advanced-OSCON2004.pdf, 
slide 114.

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




More information about the wxpython-users mailing list