[wxPython-users] tell if gridevent (wx.EVT_GRID_SELECT_CELL) originated from user

Robin Dunn robin at alldunn.com
Mon Jun 4 09:53:17 PDT 2007


Eric Ongerth wrote:
> 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!





More information about the wxpython-users mailing list