pyface.data_view.abstract_data_exporter module

class pyface.data_view.abstract_data_exporter.AbstractDataExporter[source]

Bases: ABCHasStrictTraits

ABC for classes that export data from a data view.

Concrete classes should implement the get_data method so that it produces a value that can be serialized using the provided format. Some convenience methods are provided to get text values, as that is a common use-case.

format = Instance(DataFormat)

The DataFormat used to serialize the exported data.

is_text = Bool()

Whether to get item data from the text channel, if available.

add_data(data_wrapper, model, indices)[source]

Add data to the data wrapper from the model and indices.

Parameters
  • data_wrapper (DataWrapper) – The data wrapper that will be used to export data.

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

  • indices (list of (row, column) index pairs) – The indices where the data is to be stored.

abstract get_data(model, indices)[source]

Get the data to be exported from the model and indices.

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

  • indices (list of (row, column) index pairs) – The indices where the data is to be stored.

Returns

data – The data, of a type that can be serialized by the format.

Return type

Any

get_value(model, row, column)[source]

Utility method to extract a value at a given index.

If is_text is True, it will use the get_text() method to extract the value, otherwise it will try to use the editor value if it exists, and failing that the raw value returned from the model.