def ResetView(self, grid): """ (wx.grid.Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid.BeginBatch() for current, new, delmsg, addmsg in [ (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), ]: if new < current: msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) grid.ProcessTableMessage(msg) elif new > current: msg = wx.grid.GridTableMessage(self,addmsg,new-current) grid.ProcessTableMessage(msg) self.UpdateValues(grid) grid.EndBatch() self._rows = self.GetNumberRows() self._cols = self.GetNumberCols() # update the column rendering scheme self._updateColAttrs(grid) # update the scrollbars and the displayed part of the grid grid.AdjustScrollbars() grid.ForceRefresh()
def resetRows(self, grid, before): """ (Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid.BeginBatch() current = self.GetNumberRows() if current < before: msg = wx.grid.GridTableMessage( self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, current, before - current) grid.ProcessTableMessage(msg) elif current > before: msg = wx.grid.GridTableMessage( self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, current - before) grid.ProcessTableMessage(msg) self.updateValues(grid) grid.EndBatch() # update the column rendering plugins #self._updateColAttrs(grid) # update the scrollbars and the displayed part of the grid grid.AdjustScrollbars() grid.ForceRefresh()
def ResetGrid(self, oldNumRows): """ Call this to update the grid if rows and columns have been added or deleted. """ grid = self.grid grid.BeginBatch() new = self.GetNumberRows() delmsg = wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED addmsg = wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED if new < oldNumRows: msg = wx.grid.GridTableMessage(self, delmsg, new, oldNumRows - new) grid.ProcessTableMessage(msg) elif new > oldNumRows: msg = wx.grid.GridTableMessage(self, addmsg, new - oldNumRows) grid.ProcessTableMessage(msg) msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) grid.ProcessTableMessage(msg) grid.EndBatch() grid.AdjustScrollbars() grid.ForceRefresh()
def ResetView(self): grid = self.getGrid() if grid is not None: grid.ProcessTableMessage( wx.grid.GridTableMessage( self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)) self._rows = self.GetNumberRows() grid.AdjustScrollbars() grid.ForceRefresh()
def ResetView(self): """ (Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid = self.grid current_rows = self.grid.GetNumberRows() current_cols = self.grid.GetNumberCols() grid.BeginBatch() for current, new, delmsg, addmsg in [ (current_rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), (current_cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED) ]: if new < current: msg = wx.grid.GridTableMessage(self, delmsg, new, current - new) grid.ProcessTableMessage(msg) elif new > current: msg = wx.grid.GridTableMessage(self, addmsg, new - current) grid.ProcessTableMessage(msg) self.UpdateValues() grid.EndBatch() # Reset cell sizes to standard cell size grid.SetDefaultRowSize(grid.GetDefaultRowSize(), resizeExistingRows=True) grid.SetDefaultColSize(grid.GetDefaultColSize(), resizeExistingCols=True) # Adjust rows row_heights = grid.code_array.row_heights for key in row_heights: if key[1] == grid.current_table and \ key[0] < self.code_array.shape[0]: row = key[0] if row_heights[key] is None: # Default row size grid.SetRowSize(row, grid.GetDefaultRowSize()) else: grid.SetRowSize(row, row_heights[key]) # Adjust columns col_widths = grid.code_array.col_widths for key in col_widths: if key[1] == grid.current_table and \ key[0] < self.code_array.shape[1]: col = key[0] if col_widths[key] is None: # Default row size grid.SetColSize(col, grid.GetDefaultColSize()) else: grid.SetColSize(col, col_widths[key]) # update the scrollbars and the displayed part # of the grid grid.Freeze() grid.AdjustScrollbars() grid.Refresh() grid.Thaw()