pyface.data_view.value_types.editable_value module

class pyface.data_view.value_types.editable_value.EditableValue

Bases: pyface.data_view.abstract_value_type.AbstractValueType

A base class for editable values.

This class provides two things beyond the base AbstractValueType: a trait is_editable which allows toggling editing state on and off, and an is_valid method that is used for validation before setting a value.

is_editable = Bool(True, update_value_type=True)

Whether or not the value is editable, assuming the underlying data can be set.

is_valid(model, row, column, value)

Whether or not the value is valid for the data item specified.

The default implementation returns True for all values.

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 validate.

Returns

is_valid – Whether or not the value is valid.

Return type

bool

has_editor_value(model, row, column)

Return whether or not the value can be edited.

A cell is editable if the underlying data can be set, and the is_editable flag is set to True

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

bool

set_editor_value(model, row, column, value)

Set the edited value.

Parameters
  • model (AbstractDataModel) – The data model holding the data.

  • row (sequence of int) – The row in the data model being set.

  • column (sequence of int) – The column in the data model being set.

  • value (any) – The value being set.

Raises

DataViewSetError – If the value cannot be set.