Robin Dunn wrote:
Frank Millman wrote:
> Hi all
>
> There have been a number of posts in the past about getting a
> GridCellBoolEditor to behave the same as a normal CheckBox. I am
> trying this, and I am getting close - see attached program.
>
> However, I still have some questions.
>
> 1. Is there an equivalent of EVT_CHECKBOX to indicate that
the box has
> been checked/unchecked? At present, if the user clicks with
a mouse, I
> can detect it because I can detect the mouse click. But if the user
> tabs to the cell and presses 'space', the cell is changed, but I
> cannot detect it until the user moves off the cell, when
SetValue() is called.
You can catch the EVT_GRID_EDITOR_CREATED event, and then
call evt.GetControl to get a reference to the checkbox and
then bind a handler to it.
Thanks for this tip - I would never have figured it out by myself.
It needed quite a few tweaks before I could get it to behave itself, but it
seems to be working correctly now. See attached program fm48.py if you are
interested.
>
> 2. Two images for a 'checked' box seem to be used - one while the
> editor is active and one when it is not. I assume that the
former is
> drawn by GridCellBoolEditor and the latter is drawn by
> GridCellBoolRenderer. On GTK2 the images are wildly
different, and the
> second one looks hideous. On MSW the difference is less
marked, but it
> is still there. Would it not make sense for them to use the
same image?
One is a native checkbox widget, and one is just a
representation of the value drawn on a DC. If you want them
to be the same then you could write your own custom control
and a cell editor that uses it, and also a renderer class
that draws the value the same way that the custom control
does. The only thing you would lose is the use of the native widget.
I guess my main concern is the image drawn by the renderer on GTK2. If I
felt strongly enough, I might try a custom renderer to draw it better. Does
anyone else agree with me that it looks horrible?
>
> 3. On MSW, if the editor is active (either by clicking on
the cell or
> by tabbing to it), it takes two tab presses to move to the
next cell -
> one to close the editor, and one to do the move. Is there
any way to
> get rid of the first step?
The tab that dismisses the editor should also cause it to
move to the next cell, and it seems to be doing that just
fine for me in the demo.
If it's not working for you then I expect that something you
have done is overriding default behavior.
I confirm that it does not happen in the demo, but for the life of me I
cannot see what is different in my program. I have attached a very
stripped-down version, fm49.py, that shows the faulty behaviour. Would you
mind checking to see if you get the same effect that I do, and if so, can
you pinpoint the reason? My platform is wxPython 2.8.0.1, Python 2.5, MS
Windows Server 2003. To see the behaviour, do the following -
If you tab twice, it correctly moves to column 2 and then column 3.
If you tab once, then press 'space', it correctly invokes the editor and
toggles the value. If you then press tab, it closes the editor, but stays on
column 2. You have to press tab again to move to column 3.
Thanks
Frank
fm48.py (1.87 KB)
fm49.py (822 Bytes)