********************* wx.grid.GridTableBase ********************* Inheritance diagram for `wx.grid.GridTableBase`: | .. inheritance-diagram:: wx.grid.GridTableBase | Description =========== The almost abstract base class for grid tables. A grid table is responsible for storing the grid data and, indirectly, grid cell attributes. The data can be stored in the way most convenient for the application but has to be provided in string form to `wx.grid.Grid `_. It is also possible to provide cells values in other formats if appropriate, e.g. as numbers. This base class is not quite abstract as it implements a trivial strategy for storing the attributes by forwarding it to `wx.grid.GridCellAttrProvider` and also provides stubs for some other functions. However it does have a number of pure virtual methods which must be implemented in the derived classes. Derived From ^^^^^^^^^^^^^ * `wx.Object <../Widgets/wx.Object.html>`_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.grid.GridStringTable`, `wx.grid.PyGridTableBase` Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `AppendCols <#AppendCols>`_ * `AppendRows <#AppendRows>`_ * `CanGetValueAs <#CanGetValueAs>`_ * `CanHaveAttributes <#CanHaveAttributes>`_ * `CanSetValueAs <#CanSetValueAs>`_ * `Clear <#Clear>`_ * `DeleteCols <#DeleteCols>`_ * `DeleteRows <#DeleteRows>`_ * `GetAttr <#GetAttr>`_ * `GetAttrProvider <#GetAttrProvider>`_ * `GetColLabelValue <#GetColLabelValue>`_ * `GetNumberCols <#GetNumberCols>`_ * `GetNumberRows <#GetNumberRows>`_ * `GetRowLabelValue <#GetRowLabelValue>`_ * `GetTypeName <#GetTypeName>`_ * `GetValue <#GetValue>`_ * `GetValueAsBool <#GetValueAsBool>`_ * `GetValueAsDouble <#GetValueAsDouble>`_ * `GetValueAsLong <#GetValueAsLong>`_ * `GetView <#GetView>`_ * `InsertCols <#InsertCols>`_ * `InsertRows <#InsertRows>`_ * `IsEmptyCell <#IsEmptyCell>`_ * `SetAttr <#SetAttr>`_ * `SetAttrProvider <#SetAttrProvider>`_ * `SetColAttr <#SetColAttr>`_ * `SetColLabelValue <#SetColLabelValue>`_ * `SetRowAttr <#SetRowAttr>`_ * `SetRowLabelValue <#SetRowLabelValue>`_ * `SetValue <#SetValue>`_ * `SetValueAsBool <#SetValueAsBool>`_ * `SetValueAsDouble <#SetValueAsDouble>`_ * `SetValueAsLong <#SetValueAsLong>`_ * `SetView <#SetView>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `AttrProvider <#AttrProvider>`_ * `NumberCols <#NumberCols>`_ * `NumberRows <#NumberRows>`_ * `View <#View>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings available for this method.` -------- .. method:: AppendCols(numCols=1) Exactly the same as `AppendRows <#AppendRows>`_ but for columns. **Parameters:** * `numCols` (long): The number of columns to add. | **Returns:** `bool` -------- .. method:: AppendRows(numRows=1) Append additional rows at the end of the table. This method is provided in addition to `InsertRows <#InsertRows>`_ as some data models may only support appending rows to them but not inserting them at arbitrary locations. In such case you may implement this method only and leave `InsertRows` unimplemented. **Parameters:** * `numRows` (long) : The number of rows to add. | **Returns:** `bool` -------- .. method:: CanGetValueAs(row, col, typeName) Returns ``True`` if the value of the given cell can be accessed as if it were of the specified type. By default the cells can only be accessed as strings. **Parameters:** * `row` (int) * `col` (int) * `typeName` (string) | **Returns:** `bool` .. note:: Note that a cell could be accessible in different ways, e.g. a numeric cell may return true for ``wx.grid.GRID_VALUE_NUMBER`` but also for ``wx.grid.GRID_VALUE_STRING`` indicating that the value can be coerced to a string form. -------- .. method:: CanHaveAttributes() Returns ``True`` if this table supports attributes or ``False`` otherwise. By default, the table automatically creates a `wx.grid.GridCellAttrProvider` when this function is called if it had no attribute provider before and returns ``True``. | **Returns:** `bool` -------- .. method:: CanSetValueAs(row, col, typeName) Returns ``True`` if the value of the given cell can be set as if it were of the specified type. **Parameters:** * `row` (int) * `col` (int) * `typeName` (string) | **Returns:** `bool` .. seealso:: `CanGetValueAs <#CanGetValueAs>`_ -------- .. method:: Clear() Clear the table contents. Modifying the table structure. Notice that none of these functions are pure virtual as they don't have to be implemented if the table structure is never modified after creation, i.e. neither rows nor columns are never added or deleted but that you do need to implement them if they are called, i.e. if your code either calls them directly or uses the matching `wx.grid.Grid` methods, as by default they simply do nothing which is definitely inappropriate. This method is used by `wx.grid.Grid.ClearGrid `_. -------- .. method:: DeleteCols(pos=0, numCols=1) Exactly the same as `DeleteRows <#DeleteRows>`_ but for columns. **Parameters:** * `pos` (long): The first column to delete. * `numCols` (long): The number of columns to delete. | **Returns:** `bool` -------- .. method:: DeleteRows(pos=0, numRows=1) Delete rows from the table. **Parameters:** * `pos` (long): The first row to delete. * `numRows` (long): The number of rows to delete. | **Returns:** `bool` -------- .. method:: GetAttr(row, col) Return the attribute for the given cell. By default forwarded to `wx.grid.GridCellAttrProvider` if any. May be overridden to handle attributes directly in the table. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `wx.grid.GridCellAttr `_ -------- .. method:: GetAttrProvider() Get the currently used attr provider (may be ``None``). This function may return ``None`` if the attribute provider hasn't been neither associated with this table by `SetAttrProvider <#SetAttrProvider>`_ nor created on demand by any other methods. | **Returns:** `wx.grid.GridCellAttrProvider` -------- .. method:: GetColLabelValue(col) Return the label of the specified column. **Parameters:** * `col` (int) | **Returns:** `string` -------- .. method:: GetNumberCols() Must be overridden to return the number of columns in the table. | **Returns:** `int` -------- .. method:: GetNumberRows() Must be overridden to return the number of rows in the table. | **Returns:** `int` -------- .. method:: GetRowLabelValue(row) Return the label of the specified row. By default the numbers are used for labeling rows and Latin letters for labeling columns. If the table has more than 26 columns, the pairs of letters are used starting from the 27-th one and so on, i.e. the sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ZZ, AAA, ... **Parameters:** * `row` (int) | **Returns:** `string` -------- .. method:: GetTypeName(row, col) Returns the type of the value in the given cell. By default all cells are strings and this method returns ``wx.grid.GRID_VALUE_STRING``. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `string` -------- .. method:: GetValue(row, col) Must be overridden to implement accessing the table values as text. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `string` -------- .. method:: GetValueAsBool(row, col) Returns the value of the given cell as a boolean. This should only be called if `CanGetValueAs <#CanGetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_BOOL`` argument. Default implementation always return ``False``. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `bool` -------- .. method:: GetValueAsDouble(row, col) Returns the value of the given cell as a double. This should only be called if `CanGetValueAs <#CanGetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_FLOAT`` argument. Default implementation always return 0.0. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `double` -------- .. method:: GetValueAsLong(row, col) Returns the value of the given cell as a long integer. This should only be called if `CanGetValueAs <#CanGetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_NUMBER`` argument. Default implementation always return 0. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `long` -------- .. method:: GetView() Returns the last grid passed to `SetView <#SetView>`_. | **Returns:** `wx.grid.Grid `_ -------- .. method:: InsertCols(pos=0, numCols=1) Exactly the same as `InsertRows <#InsertRows>`_ but for columns. **Parameters:** * `pos` (long): The position of the first new column. * `numCols` (long) : The number of columns to insert. | **Returns:** `bool` -------- .. method:: InsertRows(pos=0, numRows=1) Insert additional rows at the end of the table. **Parameters:** * `pos` (long): The position of the first new row. * `numRows` (long) : The number of rows to insert. | **Returns:** `bool` -------- .. method:: IsEmptyCell(row, col) Must be overridden to implement testing for empty cells. **Parameters:** * `row` (int) * `col` (int) | **Returns:** `bool` -------- .. method:: SetAttr(attr, row, col) Set attribute of the specified cell. By default this function is simply forwarded to `wx.grid.GridCellAttrProvider.SetAttr`. The table takes ownership of `attr`, i.e. will call `DecRef() `_ on it. **Parameters:** * `attr` (`wx.grid.GridCellAttr `_) * `row` (int) * `col` (int) -------- .. method:: SetAttrProvider(attrProvider) Attributes management. By default the attributes management is delegated to `wx.grid.GridCellAttrProvider` class. You may override the methods in this section to handle the attributes directly if, for example, they can be computed from the cell values. Associate this attributes provider with the table. The table takes ownership of `attrProvider` pointer and will delete it when it doesn't need it any more. The pointer can be ``None``, however this won't disable attributes management in the table but will just result in a default attributes being recreated the next time any of the other functions in this section is called. To completely disable the attributes support, should this be needed, you need to override `CanHaveAttributes <#CanHaveAttributes>`_ to return ``False``. **Parameters:** * `attrProvider` (`wx.grid.GridCellAttrProvider`) -------- .. method:: SetColAttr(attr, col) Set attribute of the specified column. By default this function is simply forwarded to `wx.grid.GridCellAttrProvider.SetColAttr`. The table takes ownership of `attr`, i.e. will call `DecRef() `_ on it. **Parameters:** * `attr` (`wx.grid.GridCellAttr `_) * `col` (int) -------- .. method:: SetColLabelValue(col, label) Exactly the same as `SetRowLabelValue <#SetRowLabelValue>`_ but for columns. **Parameters:** * `col` (int) * `label` (string) -------- .. method:: SetRowAttr(attr, row) Set attribute of the specified row. By default this function is simply forwarded to `wx.grid.GridCellAttrProvider.SetRowAttr`. The table takes ownership of `attr`, i.e. will call `DecRef() `_ on it. **Parameters:** * `attr` (`wx.GridCellAttr `_) * `row` (int) -------- .. method:: SetRowLabelValue(row, label) Set the given label for the specified row. The default version does nothing, i.e. the label is not stored. You must override this method in your derived class if you wish `wx.grid.Grid.SetRowLabelValue `_ to work. **Parameters:** * `row` (int) * `label` (string) -------- .. method:: SetValue(row, col, value) Must be overridden to implement setting the table values as text. **Parameters:** * `row` (int) * `col` (int) * `value` (string) -------- .. method:: SetValueAsBool(row, col, value) Sets the value of the given cell as a boolean. This should only be called if `CanSetValueAs <#CanSetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_BOOL`` argument. Default implementation doesn't do anything. **Parameters:** * `row` (int) * `col` (int) * `value` (bool) -------- .. method:: SetValueAsDouble(row, col, value) Sets the value of the given cell as a double. This should only be called if `CanSetValueAs <#CanSetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_FLOAT`` argument. Default implementation doesn't do anything. **Parameters:** * `row` (int) * `col` (int) * `value` (double) -------- .. method:: SetValueAsLong(row, col, value) Sets the value of the given cell as a long integer. This should only be called if `CanSetValueAs <#CanSetValueAs>`_ returns ``True`` when called with ``wx.grid.GRID_VALUE_NUMBER`` argument. Default implementation doesn't do anything. **Parameters:** * `row` (int) * `col` (int) * `value` (long) -------- .. method:: SetView(grid) Called by the grid when the table is associated with it. The default implementation stores the pointer and returns it from its `GetView <#GetView>`_ and so only makes sense if the table cannot be associated with more than one grid at a time. Overriding this method is optional. **Parameters:** * `grid` (`wx.grid.Grid `_) -------- Properties ^^^^^^^^^^ .. attribute:: AttrProvider See `GetAttrProvider <#GetAttrProvider>`_ and `SetAttrProvider <#SetAttrProvider>`_ .. attribute:: NumberCols See `GetNumberCols <#GetNumberCols>`_ .. attribute:: NumberRows See `GetNumberRows <#GetNumberRows>`_ .. attribute:: View See `GetView <#GetView>`_ and `SetView <#SetView>`_