[wxPython-users] wxButton in a wxGrid cell?
Robin Dunn
robin at alldunn.com
Fri Sep 1 08:36:06 PDT 2006
A.M. wrote:
> Hi all,
>
> I am basically trying to achieve the look and feel of a regular
> wxButton but instead of placing it on a panel, dialog, etc...I would
> like to have it in a cell of the grid. I've looked into both renderers
> and editors and it seems like I wouldn't even need an editor since
> there is nothing to edit, but then the renderer, at first glance,
> doesn't allow wx controls to be "plugged in" since I must handle the
> drawing of the control myself.
Yeah, that's an unfortunate short-coming of the Grid class. It would be
nice if it optionally allowed a renderer to be a control. You might be
able to get fairly good results however by managing the placement and
size of the control yourself. You can create it as a child of
grid.GetGridWindow(), and then use grid.CellToRect(row, col) to know
where to place it (adjusted for the size of the label windows) and then
catch the row and col size events to adjust it later if needed.
>
> This is fine, I've looked at examples and I feel confident that I can
> do it, however, one major goal of this is to keep it acting like a
> real button including the hover and toggle effects that occur with
> normal mouse events. How to provide that functionality isn't readily
> apparent.
>
> So, my question is how can I accomplish this? Or at least fake it :)
If the above doesn't work out then you can borrow some button-like
drawing code from wx/lib/buttons.py. It won't have the native look, but
it should still look like a button.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list