Hey Frank,
Does this help?
Change wxGrid CheckBox with one click - wxPyWiki
Frank Millman
Not really. I started there, and tried to a nearly exact copy of your
code, but was constantly having problems - too many to untangle in a
coherent manner.
So I scaled back and started looking at what was working and what was
not. The problem seems to be the default boolean renderer - I can't
get it to respond to any of the events that I think it should.
I had tried a couple of refresh type methods, but certainly not that
one. Maybe I should try the default renderer again with that refresh.
That's probably the event that I was missing.
@Raffaello
- How do you want the editor to behave?.
- How do you toggle the value in the cell ? I mean, do you use
wxGrid::SetCellValue or wxGridTableBase::SetValue or
wxGridTableBase::SetValueAsBool?
I don't really want the editor at all. I don't like the way the look
changes between the renderer and editor. What I want is for a single
click (or keypress, for that matter), to toggle the boolean value. In
the most ideal case, it'll behave exactly like a checkbox - heck, even
*look* exactly like a check box. It should toggle every time it is
clicked. It should never change appearance (i.e. no discrepancies
between the renderer and editor). It should never expose an editor or
any other hints of what is going on behind the scenes - it should just
toggle every time it is frobbed by any sort of user event.
It seems to me that this would be a pretty common use case for a
boolean render. If I get this cleaned up, maybe I'll see about
posting it.
I actually have a decent half-working solution. Currently I toggle
the value in a mouse handler using Grid.SetCellValue(), then raise a
CELL_CHANGE event. I wrote a custom renderer following Robin's
example from wxPython In Action that just displays a checkmark for
True or an empty string for False. This actually works fairly well,
though I don't yet handle key press events. The downfall is that it
doesn't give you any hints that you should click it. It just looks
like a plain cell when it is false.
I'll go try the default bool renderer and Robin's refresh suggestion.
We'll see if that behaves nicely
I've got questions about custom cell editors, too, but I don't think
that should be part of this thread.
Thanks,
James