qudi.util.mapper.Mapper

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.

__init__(**kwargs)[source]

Methods

__init__(**kwargs)

add_mapping(widget, model, model_getter[, ...])

Adds a mapping.

clear_mapping()

Clears all mappings.

remove_mapping(widget[, widget_property_name])

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

revert()

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

submit()

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

Attributes

submit_policy

Returns the submit policy.

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.