pyface.data_view.value_types.enum_value module

class pyface.data_view.value_types.enum_value.EnumValue[source]

Bases: pyface.data_view.value_types.editable_value.EditableValue

Editable value that takes one of a collection of pre-set values.

Each value can be associated with text, colors and images by supplying functions format, colors and images, respectively.

values = List()

The list of values which are allowed for the value.

format = Callable(str, update_value_type=True)

A function that converts a value to a string for display.

colors = Callable(None, update_value_type=True)

A map from valid values to colors.

images = Callable(None, update_value_type=True)

A map from valid values to images.

is_valid(model, row, column, value)[source]

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

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_text(model, row, column)[source]

Get the display text from 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 text to display.

Return type

str

get_text(model, row, column)[source]

Get the display text from 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 text to display.

Return type

str

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

bool

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

Color instance

has_image(model, row, column)[source]

Whether or not the value has an image associated with it.

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

bool

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

IImage