qudi.util.mapper

This file contains the Qudi mapper module.

Classes

Converter()

Class for converting data between display and storage (i.e. widget and model).

Mapper(**kwargs)

The Mapper connects a Qt widget for displaying and editing certain data types with a model property or setter and getter functions.

class qudi.util.mapper.Converter[source]

Bases: builtins.object

Class for converting data between display and storage (i.e. widget and model).

model_to_widget(data)[source]

Converts data from the model format to the widget data format.

Parameters:
dataobject

Data to be converted from the model format to the widget format.

Returns:
object

Converted data in the widget format.

widget_to_model(data)[source]

Converts data from the format given by the widget to the model data format.

Parameters:
dataobject

Data to be converted.

Returns:
object

Converted data.

class qudi.util.mapper.Mapper(**kwargs)[source]

Bases: builtins.object

The Mapper connects a Qt widget for displaying and editing certain data types with a model property or setter and getter functions. The model can be e.g. a logic or a hardware module.

add_mapping(widget, model, model_getter, model_property_notifier=None, model_setter=None, widget_property_name='', widget_property_notifier=None, converter=None)[source]

Adds a mapping.

Parameters:
widget QtWidget A widget displaying some data. You want to map this

widget to model data

model object Instance of a class holding model data (e.g. a logic

or hardware module)

model_getter property/callable either a property holding the data to

be displayed in widget or a getter method to retrieve data from the model was changed.

model_property_notifier Signal A signal that is fired when the data

was changed. Default: None. If None then data changes are not monitored and the widget is not updated.

model_setter callable A setter method which is called to set data to

the model. If model_getter is a property the setter can be determined from this property and model_setter is ignored if it is None. If it is not None always this callable is used. Default: None

widget_property_name str The name of the pyqtProperty of the widget

used to map the data. Default: ‘’ If it is an empty string the relevant property is guessed from the widget’s type.

widget_property_notifier Signal Notifier signal which is fired by the

widget when the data changed. If None this is determined directly from the property. Example usage: QLineEdit().editingFinished Default: None

converter Converter converter instance for converting data between

widget display and model. Default: None

clear_mapping()[source]

Clears all mappings.

remove_mapping(widget, widget_property_name='')[source]

Removes the mapping which maps the QtWidget widget to some model data.

Parameters:
widget: QtWidget/(QtWidget, str) widget the mapping is attached to

or a tuple containing the widget and the widget’s property name

widget_property_name: str name of the property of the widget we are

dealing with. If ‘’ it will be determined from the widget. Default: ‘’

revert()[source]

Takes the data stored in the models and displays them in the widgets.

submit()[source]

Submits the current values stored in the widgets to the models.

property submit_policy

Returns the submit policy.