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

Jorgen Bodde jorgen.maillist at gmail.com
Fri Dec 14 03:03:53 PST 2007


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'm asking this because I am close to releasing a code generator tool
called CVL which allows people to customize a code base like a
wx.PyControl to tailor it, and start their work from there. I am
already looking into creating a good solid wxPython Framework that
people can use (e.g. with standard menu, icons, toolbar, about box
etc).

With regards,
- Jorgen

On Dec 13, 2007 10:50 PM, Robin Dunn <robin at alldunn.com> wrote:
> Cody Precord wrote:
>
> > For a more complete picture download the source and run the included
> > demo (PlateButtonDemo.py):
> >
>
> Looks nice.  Here are a few tips for custom controls in general, and
> also a few things I noticed about this one:
>
> * You should allow all the standard widget args in the __init__ method,
> so people don't have to look at your code to know what parameters it
> accepts, or for tools like XRCed.  You're missing pos, size, and name.
> Pass them all on to the base class __init__.
>
> * For playing nice with sizers you should call SetInitialSize from the
> __init__, passing the size that was given as a parameter, default to
> wx.DefaultSize.  This will do a couple things.  1) will set the size of
> the widget either to the size passed in, or to the best size if one or
> both of the size components are given as default values.  2) Will set
> the widget's minsize to the size given.
>
> * Also for playing nice with sizers, and with the previous item, you
> should implement a DoGetBestSize method that calculates and returns a
> wx.Size that is the optimal size of the widget based on its label, font
> size, image size, style, etc. In this case your DoGetBestSize could be
> just your current __CalcBestSize without the lines at the end that
> actually set the size.  Let the user, sizer, or things like
> SetInitialSize do that part for you instead.  All your calls to
> __CalcBestSize could probably be removed, or if you use CacheBestSize
> then they can be replaced with InvalidaeBestSize.
>
> * You can also override AcceptsFocus, although the default in the base
> class is probably good enough for this widget....
>
> * I noticed that the text color chosen on Windows for when the button is
> in the pressed state is almost unreadable.
>
> * I would make the activation key be WXK_SPACE on all platforms, not
> just windows.
>
> * You might also want to respond to EVT_CONTEXT_MENU for the buttons
> with a menu.  Then on Windows at least the user can get to the menu
> without using the mouse, since there is a menu key on the keyboard.
>
> * I notice that when tabbing between widgets that the previously focused
> widget loses its highlight noticeably *after* the newly focused widget
> is highlighted.  This looks really really weird.
>
> * Clicking a button isn't setting the focus there.
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>




More information about the wxpython-users mailing list