Let’s say I have a grid event (wx.EVT_GRID_SELECT_CELL) and I want to determine whether it came from the keyboard (i.e. was initiated by the user) or not.
Why am I asking? Well, most of the time if such an event passes by, it IS because the user selected a cell. However, if I clear my grid table (this is with a wx.PyGridTableBase) and then add a single row back into it, notify the grid of the change and refresh the grid, the grid seems to say “hey, there’s only one row in me. It must be the selected row!” – thus it generates a wx.EVT_GRID_SELECT_CELL.
Unfortunately, I’m binding EVT_GRID_SELECT_CELL to a method that populates a bunch of fields in a window, and I don’t want those fields populated automatically if the above chain of events happened. I only want it populated if the user actually selected a cell, not by the “default select” of the table having only one row.
I thought I’d read that there was a general method inherited from the abstract wx.Event class that returns the value I want, but it doesn’t seem to be there as such. Maybe I was just thinking of IsCommandEvent, which doesn’t appear to be what is needed here.
Let's say I have a grid event (wx.EVT_GRID_SELECT_CELL) and I want to determine whether it came from the keyboard (i.e. was initiated by the user) or not.
Why am I asking? Well, most of the time if such an event passes by, it IS because the user selected a cell. However, if I clear my grid table (this is with a wx.PyGridTableBase) and then add a single row back into it, notify the grid of the change and refresh the grid, the grid seems to say "hey, there's only one row in me. It must be the selected row!" -- thus it generates a wx.EVT_GRID_SELECT_CELL.
Unfortunately, I'm binding EVT_GRID_SELECT_CELL to a method that populates a bunch of fields in a window, and I don't want those fields populated automatically if the above chain of events happened. I only want it populated if the user actually selected a cell, not by the "default select" of the table having only one row.
The way this is usually handled is to set some flag before you do the thing that results in an induced event, and in the event handler check the status of that flag and just return immediately if it is set.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Let’s say I have a grid event (wx.EVT_GRID_SELECT_CELL) and I want to
determine whether it came from the keyboard (i.e. was initiated by the
user) or not.
Why am I asking? Well, most of the time if such an event passes by, it
IS because the user selected a cell. However, if I clear my grid table
(this is with a wx.PyGridTableBase) and then add a single row back into
it, notify the grid of the change and refresh the grid, the grid seems
to say “hey, there’s only one row in me. It must be the selected row!”
– thus it generates a wx.EVT_GRID_SELECT_CELL.
Unfortunately, I’m binding EVT_GRID_SELECT_CELL to a method that
populates a bunch of fields in a window, and I don’t want those fields
populated automatically if the above chain of events happened. I only
want it populated if the user actually selected a cell, not by the
“default select” of the table having only one row.
The way this is usually handled is to set some flag before you do the
thing that results in an induced event, and in the event handler check
the status of that flag and just return immediately if it is set.