[wxPython-users] [ANN] PlateButton Control for wxPython
Cody Precord
codyprecord at gmail.com
Fri Dec 14 09:34:06 PST 2007
Greetings,
Thanks to everyone who replied, I was able to make a number of
adjustments and a new bundled version is available:
Download Link: http://editra.org/uploads/code/PlateButton_v0.2.tar.gz
On Dec 13, 2007, at 3:50 PM, Robin Dunn 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__.
>
Added them. (I never use these so I thought it simpler to not have them)
> * 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.
>
I added the SetInitialSize call but currently have it set to use the
best size as I am not sure it makes sense for this control to be
sizeable to a size other than the best size.
> * 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.
>
This is nice to know
> * 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.
>
Made some adjustments to color adjusting/guessing code and tested
under some more themes seems to be good under most cases now.
> * I would make the activation key be WXK_SPACE on all platforms,
> not just windows.
>
Done
> * 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.
>
Added it, but I don't have any windows hardware to test it with so
not sure if it works as intended. I have windows installed in a vm
but couldn't find any key to simulate the 'menu key'. Is it safe to
assume that a control will only receive this event when it has the
focus?
> * 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.
I had introduced the delay to toggle back to normal state on a kill
focus to fix another problem of if you activate a button with the
space bar and then quickly tab to a new button it could potentially
leave the previous button(s) still highlighted. I have removed the
delay in this version as it is more likely an issue than the really
quick button activate / change focus problem will likely be.
>
> * Clicking a button isn't setting the focus there.
>
Done
> --
> 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
>
Regards,
Cody Precord
http://editra.org
More information about the wxpython-users
mailing list