pyface.data_view.value_types.color_value module

class pyface.data_view.value_types.color_value.ColorValue[source]

Bases: pyface.data_view.value_types.editable_value.EditableValue

Editable value that presents a color value.

This is suitable for use where the value returned by an item in the model is a Color object.

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

Is the given value valid for this item.

The default implementation says the value must be a Color.

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

Returns

success – Whether or not the value is valid.

Return type

bool

get_editor_value(model, row, column)[source]

Get the editable representation of the underlying value.

The default uses a text hex representation of the color.

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 – A hex string representation of the colour.

Return type

str

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

Set the editable representation of the underlying value.

The default expects a string that can be parsed to a color 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.

  • value (str) – A string that can be parsed to a color value.

Returns

success – Whether or not the value was successfully set.

Return type

bool

get_text(model, row, column)[source]

Get the textual representation of 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 – A hex string representation of the colour.

Return type

str

set_text(model, row, column, text)[source]

Set the textual representation of 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.

  • text (str) – The text to set.

Returns

success – Whether or not the value was successfully set.

Return type

bool

has_color(model, row, column)[source]

Whether or not the value has color data.

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

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