Module mappers
This module contains machinery for synchronizing models with various objects.
Various terms used in this module are defined here.
param: a data element of the type schrodinger.models.parameters.Param. Params
can be ints, bools, strings, etc., or more complex compound params that are
themselves composed of multiple params.
model: an object with one or more params, each representing some data elements
of the model. The model can by synchronized to a target object via a mapper.
target: a target is any object that we want to keep in sync with a model param.
Targets are generally GUI widgets like spinboxes or line edits, but can be a
variety of other things, such as a specific signal we want a model param to
listen to, or a pair of setter/getter functions to sync to a model param's
value. A target could also be something like a command line argument, such that
each command line argument corresponds to a different param in a model.
access: a particular way of interacting with a target. A target can have one or
more accesses - a setter, a getter, or a signal.
default access: certain target types will have default accesses defined in this
module. The default accesses for QLineEdit, for example, are: QLineEdit.text as
the getter, QLineEdit.setText as the setter, and QLineEdit.textChanged as the
signal.
mapper: a manager object that is responsible for model/target synchronization.
mapping: a defined association between a target object and a model param. Note
that the mapping is always between a specific target instance (for example a
checkbox instance), and a model *class* param (ex. MyModel.myboolparam, where
MyModel is the class). By making the association with the model's class rather
than a model instance, the mapper is able to switch between different instances
of the same model. Consider, for example,
A model class Person, with params name and age
A GUI panel with panel.name_le and panel.age_sb
Mappings:
panel.name_le -> Person.name
panel.age_sb -> Person.age
Model instances amy, bob, and charlie
We can now user mapper.setModel to switch between model instances, and the GUI
state will change accordingly.
|
Target
Describes a target that maps to a model param.
|
|
ParamTarget
Class to allow a param to be synchronized to another param.
|
|
AttrTarget
Allows an attribute on any object to be synchronized to a param.
|
|
DefaultTargetMixin
Use this mixin to enable get default Target behavior from a custom
object the way it works for standard widgets like QCheckBox and
QLineEdit.
|
|
AccessType
The different types of target access.
|
|
AbstractParamMapper
A param mapper manages synchronization between target objects that
represent various params and a model object that contains those
params.
|
|
TargetParamMapper
Maps Target objects to params in a model.
|
|
SettingsParamMapper
This class is now deprecated in favor of TargetParamMapper.
|
|
MapperMixin
Mixin that can facilitate the use of parameters and mappers for
storing the state of its subclasses.
|
|
make_mapper(map_dict,
model=None,
mapper_class=None)
Convenience function for adding many mappings at once via a
dictionary. |
|
|
|
DEFAULT = object()
|
|
DEFAULT_ACCESS_NAMES = { <class 'PyQt5.QtWidgets.QCheckBox'>: ( ...
|
|
__package__ = ' schrodinger.tasks '
|
make_mapper(map_dict,
model=None,
mapper_class=None)
|
|
Convenience function for adding many mappings at once via a
dictionary.
- Parameters:
map_dict (dict) - a dictionary with abstract parameters as keys and target objects
as values.
model (object) - an optional paramter for setting a specific model object to this
mapper. Doing so will also set this mapper as the model's primary
mapper, if possible
mapper_class (type) - an optional parameter to use if the mapper is not meant to be a
SettingsParamMapper.
|
DEFAULT_ACCESS_NAMES
- Value:
{ <class 'PyQt5.QtWidgets.QCheckBox'>: ( ' isChecked ' ,
' setChecked ' ,
' stateChanged ' ) ,
<class 'PyQt5.QtWidgets.QComboBox'>: ( ' currentIndex ' ,
' setCurrentIndex ' ,
' currentIndexChanged ' ) ,
<class 'PyQt5.QtWidgets.QDoubleSpinBox'>: ( ' value ' ,
' setValue ' ,
...
|
|