wxGrid change checkbox value in one click

Hi to all,
I have a wxGrid with a checkbox column,
I want to check / decheck on the first click.
Now if the cell is not selected it need a first click to select and a
second click to switch value. There is a way to do with only one
click?

Thanks in advance,
Luca

Luca Tavoletti wrote:

Hi to all,
I have a wxGrid with a checkbox column,
I want to check / decheck on the first click.
Now if the cell is not selected it need a first click to
select and a second click to switch value. There is a way
to do with only one click?

With some effort, yes.

I got this working a few months ago after much help from Robin. Attached is
a sample program that shows how it works. Feel free to ask if there is
anything you don't understand.

Frank Millman

fm51.py (2.72 KB)

Luca, Frank,

Below is a link to the wxWiki that proposes improvements to the comboboxes in
wxGrid.
http://www.wxwidgets.org/wiki/index.php/WxGrid
May be it could be integrated to wxpython ? No ?

Unfortunately (for me), the code is in C++...
May be someone could "translate" it into python.
If so, thanks to post the code here. I need it too.

Anyway, Frank, Thanks for this useful code
Dominique

It's perfect!!!

Thanks a lot,
Luca

···

On 5/22/07, Frank Millman <frank@chagford.com> wrote:

Luca Tavoletti wrote:
>
> Hi to all,
> I have a wxGrid with a checkbox column,
> I want to check / decheck on the first click.
> Now if the cell is not selected it need a first click to
> select and a second click to switch value. There is a way
> to do with only one click?

With some effort, yes.

I got this working a few months ago after much help from Robin. Attached is
a sample program that shows how it works. Feel free to ask if there is
anything you don't understand.

Frank Millman

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Thanks for posting that! I was able to integrate it into Dabo quite easily. Now, I'd like to take it to the next level: responding to the user checking/unchecking the checkbox immediately.

I already can respond when the editor gets hidden, but I want to respond at the moment the checkbox is toggled. The editor control doesn't raise a wx.EVT_BUTTON, unfortunately, and I don't really want to write KeyDown and Mouse handlers to decide if the user changed the value or not, although that is certainly an option. But before I go down that road, do you have any better ideas?

Thanks!

···

On 5/22/2007, Frank Millman wrote:

Luca Tavoletti wrote:

Hi to all,
I have a wxGrid with a checkbox column,
I want to check / decheck on the first click.
Now if the cell is not selected it need a first click to select and a second click to switch value. There is a way to do with only one click?

With some effort, yes.

I got this working a few months ago after much help from Robin. Attached is
a sample program that shows how it works. Feel free to ask if there is
anything you don't understand.

--
pkm ~ http://paulmcnett.com

wx.EVT_CHECKBOX?

···

On 6/19/07, Paul McNett <p@ulmcnett.com> wrote:

Thanks for posting that! I was able to integrate it into Dabo quite
easily. Now, I'd like to take it to the next level: responding to the
user checking/unchecking the checkbox immediately.

I already can respond when the editor gets hidden, but I want to respond
at the moment the checkbox is toggled. The editor control doesn't raise
a wx.EVT_BUTTON, unfortunately, and I don't really want to write KeyDown
and Mouse handlers to decide if the user changed the value or not,
although that is certainly an option. But before I go down that road, do
you have any better ideas?

--

# p.d.

Peter Decker wrote:

···

On 6/19/07, Paul McNett <p@ulmcnett.com> wrote:

Thanks for posting that! I was able to integrate it into Dabo quite
easily. Now, I'd like to take it to the next level: responding to the
user checking/unchecking the checkbox immediately.

I already can respond when the editor gets hidden, but I want to respond
at the moment the checkbox is toggled. The editor control doesn't raise
a wx.EVT_BUTTON, unfortunately, and I don't really want to write KeyDown
and Mouse handlers to decide if the user changed the value or not,
although that is certainly an option. But before I go down that road, do
you have any better ideas?

wx.EVT_CHECKBOX?

Wow, my face is indeed red right now. I don't know what I was thinking...

Anyway, wx.EVT_CHECKBOX is indeed raised: thanks!

But I noticed a new problem (that makes sense): the first toggle of the checkbox when done by the mouse doesn't raise EVT_CHECKBOX, but the others do. That's because of the way we manually toggle the checkbox with the first mouse click on it...

--
pkm ~ http://paulmcnett.com

Paul McNett wrote:

Anyway, wx.EVT_CHECKBOX is indeed raised: thanks!

But I noticed a new problem (that makes sense): the first
toggle of the checkbox when done by the mouse doesn't raise
EVT_CHECKBOX, but the others do. That's because of the way we
manually toggle the checkbox with the first mouse click on it...

That is why I created the method afterCheckBox().

It is called both from EVT_CHECKBOX and from the first mouse click.

Therefore that is the method where I put my code to actually respond to the
event.

HTH

Frank

Frank Millman wrote:

Paul McNett wrote:

Anyway, wx.EVT_CHECKBOX is indeed raised: thanks!

But I noticed a new problem (that makes sense): the first toggle of the checkbox when done by the mouse doesn't raise EVT_CHECKBOX, but the others do. That's because of the way we manually toggle the checkbox with the first mouse click on it...

That is why I created the method afterCheckBox().

It is called both from EVT_CHECKBOX and from the first mouse click.

Therefore that is the method where I put my code to actually respond to the
event.

Sounds like a good plan... Thanks Frank!

···

--
pkm ~ http://paulmcnett.com

Can anybody please send me the Frank Millman is talking about? I have a similar issue as Luca.

Appreciate your help.

Ananda

···

On 6/20/07, Paul McNett p@ulmcnett.com wrote:

Frank Millman wrote:

Paul McNett wrote:

Anyway, wx.EVT_CHECKBOX is indeed raised: thanks!

But I noticed a new problem (that makes sense): the first
toggle of the checkbox when done by the mouse doesn’t raise

EVT_CHECKBOX, but the others do. That’s because of the way we
manually toggle the checkbox with the first mouse click on it…

That is why I created the method afterCheckBox().

It is called both from EVT_CHECKBOX and from the first mouse click.

Therefore that is the method where I put my code to actually respond to the
event.

Sounds like a good plan… Thanks Frank!


pkm ~ http://paulmcnett.com


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Ananda Regmi wrote:

Can anybody please send me the Frank Millman is talking
about? I have a similar issue as Luca.

Appreciate your help.

Ananda

Er, do you mean send you the program? If so, here it is again.

Looks like this is becoming an FAQ. Maybe I should put my program on the
wiki. Any thoughts?

Frank

fm51.py (2.72 KB)

Frank Millman wrote:

Ananda Regmi wrote:

Can anybody please send me the Frank Millman is talking about? I have a similar issue as Luca.

Appreciate your help.

Ananda

Er, do you mean send you the program? If so, here it is again.

Looks like this is becoming an FAQ. Maybe I should put my program on the
wiki. Any thoughts?

Feel free to do so.

···

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

Robin Dunn wrote:

Frank Millman wrote:
> Ananda Regmi wrote:
>> Can anybody please send me the Frank Millman is talking
about? I have
>> a similar issue as Luca.
>>
>> Appreciate your help.
>>
>> Ananda
>>
>>
>
> Er, do you mean send you the program? If so, here it is again.
>
> Looks like this is becoming an FAQ. Maybe I should put my
program on
> the wiki. Any thoughts?

Feel free to do so.

Done. I filed it under Cookbook > RecipesControls.

It is my first attempt to edit the wiki - feel free to comment/criticise and
I will do what I can to improve it.

I just realised I did not add any docstrings. I will go back and put some
in, but I will wait to see if I get any other feedback first.

Frank