pyface.data_view.i_data_wrapper module¶
- class pyface.data_view.i_data_wrapper.DataFormat(mimetype: str, serialize: Callable[[Any], bytes], deserialize: Callable[[bytes], Any])[source]¶
Bases:
tuple
Information about a mimetype and serializers.
Simple namedtuple-based class that stores the mimetype, serializer and deserializer together.
- pyface.data_view.i_data_wrapper.text_format(encoding='utf-8', mimetype='text/plain')[source]¶
DataFormat factory for text mimetypes.
- class pyface.data_view.i_data_wrapper.IDataWrapper(adaptee, default=<class 'traits.adaptation.adaptation_error.AdaptationError'>)[source]¶
Bases:
Interface
Wrapper around polymorphic toolkit data object containing mimedata.
To support clipboard and drag and drop operations, toolkits need a way of generically representing data in multiple formats. This is a wrapper class that provides a toolkit independent intreface to these classes which allow the exchange of data, with types specified by MIME types.
- toolkit_data = Any()¶
The toolkit data object.
- mimetypes()[source]¶
Return a set of mimetypes holding data.
- Returns
mimetypes – The set of mimetypes currently storing data in the toolkit data object.
- Return type
set of str
- has_format(format)[source]¶
Whether or not a particular format has available data.
- Parameters
format (DataFormat) – A data format object.
- Returns
has_format – Whether or not there is data associated with that format in the underlying toolkit object.
- Return type
- get_format(format)[source]¶
The decoded data associted with the format.
- Parameters
format (DataFormat) – A data format object.
- Returns
data – The data decoded for the given format.
- Return type
Any
- set_format(format, data)[source]¶
Encode and set data for the format.
- Parameters
format (DataFormat) – A data format object.
data (Any) – The data to be encoded and stored.
- class pyface.data_view.i_data_wrapper.MDataWrapper[source]¶
Bases:
HasStrictTraits
Mixin class for DataWrappers.
This provides standard methods for using DataFormat objects, but not the low-level communication with the underlying toolkit.
- has_format(format)[source]¶
Whether or not a particular format has available data.
- Parameters
format (DataFormat) – A data format object.
- Returns
has_format – Whether or not there is data associated with that format in the underlying toolkit object.
- Return type
- get_format(format)[source]¶
The decoded data associted with the format.
- Parameters
format (DataFormat) – A data format object.
- Returns
data – The data decoded for the given format.
- Return type
Any
- set_format(format, data)[source]¶
Encode and set data for the format.
- Parameters
format (DataFormat) – A data format object.
data (Any) – The data to be encoded and stored.