schrodinger.models.advanced_mappers module

class schrodinger.models.advanced_mappers.MultiModelClassMapperMixin

Bases: schrodinger.models.mappers.MapperMixin

A mapper mixin that allows multiple model classes. To use, define the model_classes tuple with all the allowable model classes. Then define the usual defineMappings and getSignalsAndSlots methods, which are allowed to branch on self.model_class to specify model class-specific mappings and signal/slot connections.

In use, self.model_class will be set to one of the classes in self.model_classes, depending on what the current model is.

model_classes = ()
setModel(model)

Sets the model object for the mapper. Disconnects the old model, if one is set, and connects the new model. Pass in None to have no model set.

This will also update the value of self.model_class to the first class in self.model_classes of which model is an instance.

Parameters:model – the model instance or None
__init__

Initialize self. See help(type(self)) for accurate signature.

auto_update_model = True
auto_update_target = True
defineMappings()

Override this in the subclass to define mappings. Should return a list of tuples [(<target>, <param>)]. Most commonly, targets will be a basic widget, like QLineEdit or QComboBox, or a custom widget that inherits from MapperMixin or TargetMixin.

For more fine-grain custom control, instantiate a Target object, which allows custom setters, getters, and signals to be specified.

The param is an abstract param reference, e.g. MyModel.my_param.

Example:

def defineMappings(self):
    combo = self.style_combo
    return [(self.name_le, MyModel.name),
            (TargetSpec(combo,
                    getter=combo.currentText,
                    setter=combo.setCurrentText), MyModel.style),
            (self.coord_widget, MyModel.coord)]
getSignalsAndSlots(model)

Override this method to specify signal and slot pairs that need to be connected/disconnected whenever the model instance is switched using setModel. The model instance is provided as an argument so that instance-specific signals can be used, but any pairs of signals and slots may be returned from this method.

Returns:a list of 2-tuples where each tuple is a signal, slot pair
initLayOut()
initSetDefaults()
makeInitialModel()
mappedParams()

Return a list of the abstract params that are mapped to.

model_class = None
resetMappedParams()
setDefaults()
targetGetValue()
targetSetValue(value)
targetValueChanged