# HG changeset patch # User laurent # Date 1333192493 -7200 # Node ID 3c4e0d4f7a61d2fa8b87fee8daf0b65f512bc0c8 # Parent 7891872e6fd7e0d187f0e4db6ae420f9de528be0 Fix bug when grid is reset and a CellEditor is still active diff -r 7891872e6fd7 -r 3c4e0d4f7a61 controls/CustomGrid.py --- a/controls/CustomGrid.py Tue Mar 27 23:59:35 2012 +0200 +++ b/controls/CustomGrid.py Sat Mar 31 13:14:53 2012 +0200 @@ -84,7 +84,9 @@ self.DownButton.Enable(self.Editable and 0 <= row < rows - 1) def CloseEditControl(self): - self.SetGridCursor(self.GetGridCursorRow(), self.GetGridCursorCol()) + row, col = self.GetGridCursorRow(), self.GetGridCursorCol() + if row != -1 and col != -1: + self.SetGridCursor(row, col) def AddRow(self): self.CloseEditControl() diff -r 7891872e6fd7 -r 3c4e0d4f7a61 controls/CustomTable.py --- a/controls/CustomTable.py Tue Mar 27 23:59:35 2012 +0200 +++ b/controls/CustomTable.py Sat Mar 31 13:14:53 2012 +0200 @@ -69,6 +69,7 @@ (wx.grid.Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ + grid.CloseEditControl() grid.BeginBatch() for current, new, delmsg, addmsg in [ (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),