pyface.data_view.abstract_value_type module¶
Provides an AbstractValueType ABC for Pyface data models.
This module provides an ABC for data view value types, which are responsible
for adapting raw data values as used by the data model’s get_value
and
set_value
methods to the data channels that the data view expects, such
as text, color, icons, etc.
It is up to the data view to take this standardized data and determine what and how to actually display it.
- class pyface.data_view.abstract_value_type.CheckState(value)[source]¶
Bases:
IntEnum
Possible checkbox states
- UNCHECKED = 0¶
- CHECKED = 1¶
- class pyface.data_view.abstract_value_type.AbstractValueType[source]¶
Bases:
ABCHasStrictTraits
A value type converts raw data into data channels.
The data channels are editor value, text, color, image, and description. The data channels are used by other parts of the code to produce the actual display.
Subclasses should mark traits that potentially affect the display of values with
update_value_type=True
metdadata, or alternatively fire theupdated
event when the state of the value type changes.Each data channel is set up to have a method which returns whether there is a value for the channel, a second method which returns the value, and an optional third method which sets the channel value. These methods should not raise an Exception, eveen when called inappropriately (eg. calling a “get” method after a “has” method has returned False).
- updated = Event¶
Fired when a change occurs that requires updating values.
- has_editor_value(model, row, column)[source]¶
Return whether or not the value can be edited.
The default implementation is that cells that can be set are editable.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_editor_value – Whether or not the value is editable.
- Return type
- get_editor_value(model, row, column)[source]¶
Return a value suitable for editing.
The default implementation is to return the underlying data value directly from the data model.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
value – The value to edit.
- Return type
Any
- set_editor_value(model, row, column, value)[source]¶
Set a value that is returned from editing.
The default implementation is to set the value directly from the data model. Returns True if successful, False if it fails.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
value (Any) – The value to set.
- Raises
DataViewSetError – If the value cannot be set.
- has_text(model, row, column)[source]¶
Whether or not the value has a textual representation.
The default implementation returns True if
get_text
returns a non-empty value.- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_text – Whether or not the value has a textual representation.
- Return type
- get_text(model, row, column)[source]¶
The textual representation of the underlying value.
The default implementation calls str() on the underlying value.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
text – The textual representation of the underlying value.
- Return type
- set_text(model, row, column, text)[source]¶
Set the text of the underlying value.
This is provided primarily for backends which may not permit non-text editing of values, in which case this provides an alternative route to setting the value. The default implementation does not allow setting the text.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
text (str) – The text to set.
- Raises
DataViewSetError – If the value cannot be set.
- has_color(model, row, column)[source]¶
Whether or not the value has color data.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_color – Whether or not the value has data-associated color values.
- Return type
- get_color(model, row, column)[source]¶
Get data-associated colour values for the given item.
The default implementation returns white.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
color – The color associated with the cell.
- Return type
- has_image(model, row, column)[source]¶
Whether or not the value has an image associated with it.
The default implementation returns True if
get_image
returns a non-None value.- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_image – Whether or not the value has an image associated with it.
- Return type
- get_image(model, row, column)[source]¶
An image associated with the underlying value.
The default implementation returns None.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
image – The image associated with the underlying value.
- Return type
- has_check_state(model, row, column)[source]¶
Whether or not the value has checked state.
The default implementation returns False.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_check_state – Whether or not the value has a checked state.
- Return type
- get_check_state(model, row, column)[source]¶
The state of the item check box.
The default implementation returns “checked” if the value is truthy, or “unchecked” if the value is falsey.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
check_state – The current checked state.
- Return type
- set_check_state(model, row, column, check_state)[source]¶
Set the checked state of the underlying value.
The default implementation does not allow setting the checked state.
- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
check_state (CheckState) – The check state value to set.
- Raises
DataViewSetError – If the value cannot be set.
- has_tooltip(model, row, column)[source]¶
Whether or not the value has a tooltip.
The default implementation returns True if
get_tooltip
returns a non-empty value.- Parameters
model (AbstractDataModel) – The data model holding the data.
row (sequence of int) – The row in the data model being queried.
column (sequence of int) – The column in the data model being queried.
- Returns
has_tooltip – Whether or not the value has a textual representation.
- Return type