pyface.data_view.data_models.row_table_data_model module¶
A row-oriented data model implementation.
This module provides a concrete implementation of a data model for the case of non-hierarchical, row-oriented data.
- class pyface.data_view.data_models.row_table_data_model.RowTableDataModel[source]¶
Bases:
AbstractDataModel
A data model that presents a sequence of objects as rows.
The data is expected to be a sequence of row objects, each object providing values for the columns via an AbstractDataAccessor subclass. Concrete implementations can be found in the data_accessors module that get data from attributes, indices of sequences, and keys of mappings, but for more complex situations, custom accessors can be defined.
- data = Instance(Sequence, allow_none=False)¶
A sequence of objects to display as rows.
- row_header_data = Instance(AbstractDataAccessor, allow_none=False)¶
An object which describes how to map data for the row headers.
- column_data = List(Instance(AbstractDataAccessor, allow_none=False))¶
An object which describes how to map data for each column.
- index_manager = Instance(IntIndexManager, args=(), allow_none=False)¶
The index manager that helps convert toolkit indices to data view indices.
- get_column_count()[source]¶
How many columns in the data view model.
- Returns
column_count – The number of columns that the data view provides.
- Return type
non-negative int
- can_have_children(row)[source]¶
Whether or not a row can have child rows.
Only the root has children.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
- Returns
can_have_children – Whether or not the row can ever have child rows.
- Return type
- get_row_count(row)[source]¶
How many child rows the row currently has.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
- Returns
row_count – The number of child rows that the row has.
- Return type
non-negative int
- get_value(row, column)[source]¶
Return the Python value for the row and column.
This uses the row_header_data and column_data accessors to extract values for the row and column.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
- Returns
value – The value represented by the given row and column.
- Return type
Any
- can_set_value(row, column)[source]¶
Whether the value in the indicated row and column can be set.
This uses the row_header_data and column_data accessors to determine if the value may be changed.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
- Returns
can_set_value – Whether or not the value can be set.
- Return type
- set_value(row, column, value)[source]¶
Set the Python value for the row and column.
This uses the row_header_data and column_data accessors to set the value.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
value (Any) – The new value for the given row and column.
- Raises
DataViewSetError – If the value cannot be set.
- get_value_type(row, column)[source]¶
Return the value type of the given row and column.
This uses the row_header_data and column_data accessors to get the value type.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
- Returns
value_type – The value type of the given row and column, or None if no value should be displayed.
- Return type
AbstractValueType or None