Adding a button to wx.grid

1,293 views
Skip to first unread message

Cloud

unread,
Mar 3, 2010, 6:15:34 AM3/3/10
to wxPython-users
Hi!

I am trying to add a button to wx.grid cell. I know that some
questions of this sort have been already posted, but I haven't found
the answer: what is the easiest way to add to a cell something that at
least looks like a button?

Cloud

unread,
Mar 3, 2010, 1:31:38 PM3/3/10
to wxPython-users
I've understood that I need to derive from wxGridCellEditor. Any help
would be appreciated.

Mike Driscoll

unread,
Mar 3, 2010, 1:58:36 PM3/3/10
to wxPython-users

On Mar 3, 12:31 pm, Cloud <alexej.bazhe...@gmail.com> wrote:
> I've understood that I need to derive from wxGridCellEditor. Any help
> would be appreciated.

According to the FAQ, you'd need to use the generic button widget and
draw it yourself:

http://wiki.wxpython.org/Frequently%20Asked%20Questions#How_do_I_render_buttons_in_a_wxGrid.3F

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Robin Dunn

unread,
Mar 5, 2010, 12:14:54 AM3/5/10
to wxpytho...@googlegroups.com

You can make a cell renderer that uses wx.RendererNative.DrawPushButton
to make it look like a native button.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Nathan McCorkle

unread,
May 5, 2014, 12:26:18 PM5/5/14
to wxpytho...@googlegroups.com
Any updates to this? Has adding arbitrary objects to a grid been added to a latest release? Or at least adding buttons?

Nathan McCorkle

unread,
Nov 6, 2014, 12:06:35 PM11/6/14
to wxpytho...@googlegroups.com


On Thursday, March 4, 2010 9:14:54 PM UTC-8, Robin Dunn wrote:
On 3/3/10 3:15 AM, Cloud wrote:
> Hi!
>
> I am trying to add a button to wx.grid cell. I know that some
> questions of this sort have been already posted, but I haven't found
> the answer: what is the easiest way to add to a cell something that at
> least looks like a button?
>

You can make a cell renderer that uses wx.RendererNative.DrawPushButton
to make it look like a native button.

Here's an implementation I came up with, based on a Grid demo in the wxPython demos... am I doing anything poorly? Is there a better way?

GridStdEdRend__button.py
Reply all
Reply to author
Forward
0 new messages