views:

348

answers:

2

I would like to be warned when user selects the whole row in a wxGrid but I do not see an event that handles this.What is the best way to do it?

A: 

You can do this using EVT_GRID_RANGE_SELECT, and then check that the range is a single row when the handler is called.

For example, in the GridSimple.py wxPython demo, put the line in SimpleGrid.__init__

    self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnSelectRange)

And then add this to see which cells were selected.

def OnSelectRange(self, evt):
    print "on select range", evt.GetTopLeftCoords(), evt.GetBottomRightCoords()

From this you can determine whether the selection was one that you're interested in.

tom10
A: 

Actually, I figured it out. There are events like EVT_GRID_LABEL_LEFT_CLICK and then I test event.GetCol() == -1, to make sure the click is on a whole row, not a whole column.