[wxPython] buttons in grids?

Hello all,
I'm doing some work with wxGrids, and I'd like to be able to put a
button into the grid, so as to pop up a dialog or another window
that's relevant to the current row.

I've started fooling around with custom Editors and Renderers, and am
able to set a wxButton as a custom editor -- but as soon as I try to
use a class derived from wxButton, I get an invalid page fault.
wxButton may actually be sufficient for my needs, but I'm wondering if
this is an indication that I'm pushing the envelope a little too far.

I'm also confused as to how to set a button as a custom renderer,
looking at the example from the demo. Do I actually _need_ any of the
methods (Draw, Clone, GetBestSize)?

Is there a better way to do this?

Thanks,
Patricia

I'm doing some work with wxGrids, and I'd like to be able to put a
button into the grid, so as to pop up a dialog or another window
that's relevant to the current row.

I've started fooling around with custom Editors and Renderers, and am
able to set a wxButton as a custom editor -- but as soon as I try to
use a class derived from wxButton, I get an invalid page fault.
wxButton may actually be sufficient for my needs, but I'm wondering if
this is an indication that I'm pushing the envelope a little too far.

There shouldn't be a problem with using derived controls as editors. If you
want I can take a look at a sample to try and figure out what's wrong.

I'm also confused as to how to set a button as a custom renderer,
looking at the example from the demo. Do I actually _need_ any of the
methods (Draw, Clone, GetBestSize)?

This is where the real problem is. The current design doesn't allow for a
control to be the renderer for a cell. The CellRenderer needs to be
something that draws itself within the cell boundaries, so the best you
could do now is draw something that looks like a button. The good news
however is that there is already some code to do this that you can borrow
from. Look at the generic button controls in wxPython/lib/buttons.py

Is there a better way to do this?

Yes, but I think it will take some modifications to the wxGrid class to
enable it.

···

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

There shouldn't be a problem with using derived controls as
editors. If you want I can take a look at a sample to try and
figure out what's wrong.

Thanks -- for now, I think I'll just derive from a bool
editor/renderer, and get the underlying behaviour working, but I'll
probably revisit this later.

···

I'm also confused as to how to set a button as a custom renderer,
looking at the example from the demo. Do I actually _need_ any of the
methods (Draw, Clone, GetBestSize)?

This is where the real problem is. The current design doesn't allow for a
control to be the renderer for a cell. The CellRenderer needs to be
something that draws itself within the cell boundaries, so the best you
could do now is draw something that looks like a button. The good news
however is that there is already some code to do this that you can borrow
from. Look at the generic button controls in wxPython/lib/buttons.py

Is there a better way to do this?

Yes, but I think it will take some modifications to the wxGrid class to
enable it.

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users