Getting selected cells from wxGrid

Hi,

I try to get all selected cells in a wxGrid and normal selections work
quite well.

However, when I de-select a cell after selecting a row that contains
this cell, I do not get any update on the GetSelect... methods that are
shown below in the code. The unselected cell is correctly displayed
unmarked in the grid. The behavior is identical if columns
instead of rows are selected.

The wxPython demo does not display any selection-specific event (other
than OnClick) in this case.

For example, when I select row 2 and then Ctrl-Click on the first cell
inside row 2, the highlighting disappears but I do not get any
selection-related events. The functions that I use for getting the
selection do not yield updated values.

How do I catch these unselected cells or how do I get a list of
all cells in the range?

I am using wxPython 2.8.7.1 with python 2.5 on Linux (wxGTK).

Best Regards

Martin

···

###########
class MyGrid(wx.grid.Grid):
    def get_selection(self):
        """ Returns an index list of all cell that are selected in the
grid. All selection types are considered equal. If no cells are
selected, the current cell is returned."""
                
        # GetSelectedCells: individual cells selected by ctrl-clicking
        # GetSelectedRows: rows selected by clicking on the labels
        # GetSelectedCols: cols selected by clicking on the labels
        # GetSelectionBlockTopLeft
        # GetSelectionBlockBottomRight: For blocks of cells selected by
dragging # across the grid cells.
              
        dimx, dimy = self.parent.grid.dimensions[:2]
        selection = []
        selection += self.GetSelectedCells()
        selected_rows = self.GetSelectedRows()
        selected_cols = self.GetSelectedCols()
        selection += list((row, y) for row in selected_rows for y in
xrange(dimy)) selection += list((x, col) for col in selected_cols for x
in xrange(dimx)) for tl,br in zip(self.GetSelectionBlockTopLeft(),
self.GetSelectionBlockBottomRight()): selection += [(x,y) for x in
xrange(tl[0],br[0]+1) for y in xrange(tl[1], br[1]+1)] if selection ==
[]: selection = [(self.get_currentcell())]
        selection = sorted(list(set(selection)))
        return selection

mmanns@gmx.net wrote:

Hi,

I try to get all selected cells in a wxGrid and normal selections work
quite well.

However, when I de-select a cell after selecting a row that contains
this cell, I do not get any update on the GetSelect... methods that are
shown below in the code. The unselected cell is correctly displayed
unmarked in the grid. The behavior is identical if columns
instead of rows are selected.

Please enter a bug report about this, using a Component of "GUI-generic"

···

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