示例#1
0
    def refr_count(self, old_count, count, store_pos=0):
        dy = old_count - count
        if dy != 0:
            if dy > 0:
                msg = GridTableMessage(self.GetTable(),
                                       GRIDTABLE_NOTIFY_ROWS_DELETED, count,
                                       dy)
            else:
                msg = GridTableMessage(self.GetTable(),
                                       GRIDTABLE_NOTIFY_ROWS_APPENDED, -1 * dy)
            try:
                self.ProcessTableMessage(msg)
            except:
                pass

            if count > 0:
                if store_pos == 0:
                    self.SetGridCursor(0, 0)
                    self.MakeCellVisible(0, 0)
                elif store_pos == 1:
                    row = self.GetGridCursorRow()
                    if row >= count:
                        self.SetGridCursor(0, 0)
                        self.MakeCellVisible(0, 0)
                else:
                    row = self.GetGridCursorRow()
                    if row >= count:
                        self.SetGridCursor(count - 1 + self.CanAppend, 0)
                        self.MakeCellVisible(count - 1 + self.CanAppend, 0)
        if count > 0:
            self.AutoSizeColumns(True)
示例#2
0
    def ResetView(self, grid):
        """
        (wxGrid) -> Reset the grid view.   Call this to
        update the grid if rows and columns have been added or deleted
        """
        ##print 'VirtualModel.reset_view'
        grid.BeginBatch()
        for current, new, delmsg, addmsg in [
            (self._rows, self.GetNumberRows(), GRIDTABLE_NOTIFY_ROWS_DELETED,
             GRIDTABLE_NOTIFY_ROWS_APPENDED),
            (self._cols, self.GetNumberCols(), GRIDTABLE_NOTIFY_COLS_DELETED,
             GRIDTABLE_NOTIFY_COLS_APPENDED),
        ]:
            if new < current:
                msg = GridTableMessage(self, delmsg, new, current - new)
                grid.ProcessTableMessage(msg)
            elif new > current:
                msg = GridTableMessage(self, addmsg, new - current)
                grid.ProcessTableMessage(msg)
                self.UpdateValues(grid)
        grid.EndBatch()

        self._rows = self.GetNumberRows()
        self._cols = self.GetNumberCols()

        # update the renderers
        # self._updateColAttrs(grid)
        # self._updateRowAttrs(grid) too expensive to use on a large grid

        # update the scrollbars and the displayed part of the grid
        grid.AdjustScrollbars()
        grid.ForceRefresh()
示例#3
0
    def DeleteRow(self, row_number):
        'Borra las filas que se desean descartar de la interfaz'
        assert row_number < self.GetNumberRows(
        ), "Cannot delete a non-existant row."
        self.grid_data.pop(row_number)
        tbl_msg = GridTableMessage(self, GRIDTABLE_NOTIFY_ROWS_DELETED, 1)

        self.GetView().ProcessTableMessage(tbl_msg)
示例#4
0
    def SetValue(self, row, col, value):
        if value.startswith("="):
            cell = FunctionTableCell(value)
        else:
            cell = TableCell(value)

        CELLS[(row, col)] = cell

        # Notify change
        msg = GridTableMessage(None, GRIDTABLE_REQUEST_VIEW_GET_VALUES)
        self.GetView().ProcessTableMessage(msg)
示例#5
0
    def DeleteRows(self, pos, num_rows):
        """ Called when the view is deleting rows. """

        del self.data[pos:pos + num_rows]

        # Tell the grid that we've deleted some rows.
        #
        # N.B Because of a bug in wxPython we have to send a "rows appended"
        # --- message with a negative number, instead of the "rows deleted"
        #     message 8^() TINSTAFS!
        message = GridTableMessage(self, GRIDTABLE_NOTIFY_ROWS_APPENDED,
                                   -num_rows)

        # Trait event notification.
        self.model_changed = message

        return True
示例#6
0
    def SetValue(self, row, col, value):
        """ Set the value at the specified row and column. """

        try:
            self.data[row][col] = value

        except IndexError:
            # Add a new row.
            self.data.append([0] * self.GetNumberCols())
            self.data[row][col] = value

            # Tell the grid that we've added a row.
            #
            # N.B wxGridTableMessage(table, whatWeDid, howMany)
            message = GridTableMessage(self, GRIDTABLE_NOTIFY_ROWS_APPENDED, 1)

            # Trait event notification.
            self.model_changed = message
示例#7
0
 def UpdateValues(self, grid):
     """Update all displayed values"""
     # This sends an event to the grid table to update all of the values
     msg = GridTableMessage(self, GRIDTABLE_REQUEST_VIEW_GET_VALUES)
     grid.ProcessTableMessage(msg)
示例#8
0
    def NotifyGrid(self, msg, count):
        "Notifies the gird of the message and the affected count."
        tbl_msg = GridTableMessage(self, msg, count)

        self.GetView().ProcessTableMessage(tbl_msg)