schrodinger.ui.qt.widgetmixins.panelmixins module

schrodinger.ui.qt.widgetmixins.panelmixins.infer_input_mappings(TaskClass, panel_model)
class schrodinger.ui.qt.widgetmixins.panelmixins.PanelMixin(*args, **kwargs)

Bases: schrodinger.models.mappers.MapperMixin

PanelMixin makes a widget act as a panel - it supports a panel singleton, and expects to be shown as a window rather than an embedded widget.

Requires ExecutionMixin

SHOW_AS_WINDOW = True
classmethod getPanelInstance()

Return the singleton instance of this panel, creating one if necessary.

Returns:instance of this panel.
Return type:PanelMixin
classmethod panel(blocking=False, modal=False, finished_callback=None)

Open an instance of this class.

For full argument documentation, see ExecutionMixin.run.

__init__(*args, **kwargs)

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

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)]
getModel()
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()

@overrides: widgetmixins.InitMixin

initSetDefaults()

@overrides: widgetmixins.InitMixin

makeInitialModel()
mappedParams()

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

model
modelChanged
model_class = None
resetMappedParams()
runAllSlots()
setDefaults()

@overrides: af2.App

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.

Parameters:model – the model instance or None
setModelWithoutSlots(model)

This is called when this MapperMixin is a sub-widget of a parent MapperMixin. Since the slots will all be called at the end of the parent setModel, they shouldn’t be called during the sub-widget’s setModel.

setting_model()
class schrodinger.ui.qt.widgetmixins.panelmixins.CleanStateMixin

Bases: object

Mixin for use with PanelMixin. Implements two methods for saving and reverting changes to the model. Automatically saves the state of the model when a panel is run. Subclasses are responsible for calling discardChanges at the right time (e.g. when a user hits the cancel button)

run(*args, **kwargs)
setModel(model)
saveCleanState()

Copy the model as a clean state. Next time discardChanges is called, the model will be updated to reflect this current state.

discardChanges()

Revert the model to the value it was the last time saveCleanState was called.

__init__

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

class schrodinger.ui.qt.widgetmixins.panelmixins.TaskPanelMixin(*args, **kwargs)

Bases: schrodinger.ui.qt.widgetmixins.panelmixins.PanelMixin

A panel where the overall panel is associated with one or more panel tasks. One task is active at any time; this task will be sync’ed to the panel state and the bottom taskbar of the panel will be associated with the active task (i.e. job options will pertain to the active task, and clicking the run button will start that task).

DEPENDENCIES: widgetmixins.MessageBoxMixin

PANEL_TASKS = ()
initSetUp()
initSetDefaults()

@overrides: widgetmixins.InitMixin

initLayOut()

@overrides: widgetmixins.InitMixin

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.

Parameters:model – the model instance or None
getSettingsMenuActions(abstract_task)

Return a tuple representation of the settings button menu for a given abstract_task. For custom menus, override this method and return a list of tuples mapping desired menu item texts mapped to the method or function that should be called when the item is selected.

The following menu items are used for the default implementation:

‘Job Settings’ -> Opens up a config dialog ‘Preferences…’ -> Opens the Maestro preferences dialog to the

job preferences page.

‘Write’ -> Write the job to a bash file

—-(The above items are only shown if the task is a jobtask)———
*’Write STU ZIP File’ -> Write a zip file that can be used to
create a stu test.

‘Reset Entire Panel’ -> Resets the entire panel ‘Reset This Task’ -> Reset just the current task (hidden if there’s

only one type of task for the panel.

*’Start debugger…’ -> Start a command line debugger with IPython *’Start debugger GUI…’ -> Open up the debugger gui

    • Menu items that are only shown if the user has SCHRODINGER_SRC defined in their environment.
Parameters:abstract_task (tasks.AbstractTask) – The task to retrieve menu actions for. It will always be a member of self.PANEL_TASKS.
Returns:A list of tuples mapping the desired menu item text with the function that should be called when the item is selected. If the slot is None, then a separator will be added instead and the text will be ignored.

:rtype : list[tuple(str, callable) or None]

setBaseName(base_name, index=None)

Set the base name used for naming tasks.

Parameters:
  • base_name (str) – The new base name to use
  • index (int or None) – The index of the task type to set the new base name for. If set to None, the active task type will be used.
defineTaskPreprocessors(model)

Return a list of tuples containing a task and an associated preprocesor.

To include preprocessors, override this method in a subclass. Example:

def defineTaskPreprocessors(self, model):
    return [
        (model.search_task, self._validateSearchTerms),
        (model.email_task, self._compileAddresses)
    ]
Parameters:model (parameters.CompoundParam) – a model instance
Returns:a list of (task, method) tuples
Return type:list[tuple[tasks.AbstractTask, typing.Callable]]
defineTaskPostprocessors(model)

Return a list of tuples containing a task and an associated postprocessor.

The signature of this method is identical to that of defineTaskPreprocessors().

Parameters:model (parameters.CompoundParam) – a model instance
Returns:a list of (task, method) tuples
Return type:list[tuple[tasks.AbstractTask, typing.Callable]]
setActiveTaskIndex(index)

Select the active task based on index. This is usually used as a slot for a QComboBox.currentIndexChanged or QButtonGroup.buttonClicked signal that controls the active task of the panel.

Parameters:index (int) – 0-based index for tasks in the order they were added.
getTask(index=None)

The active task instance. This is the task instance that will be run if the start button is clicked.

getTaskBar(index=None)

Gets the active task’s taskbar.

getTaskManager(index=None)
SHOW_AS_WINDOW = True
__init__(*args, **kwargs)

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

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)]
getModel()
classmethod getPanelInstance()

Return the singleton instance of this panel, creating one if necessary.

Returns:instance of this panel.
Return type:PanelMixin
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
makeInitialModel()
mappedParams()

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

model
modelChanged
model_class = None
classmethod panel(blocking=False, modal=False, finished_callback=None)

Open an instance of this class.

For full argument documentation, see ExecutionMixin.run.

resetMappedParams()
runAllSlots()
setDefaults()

@overrides: af2.App

setModelWithoutSlots(model)

This is called when this MapperMixin is a sub-widget of a parent MapperMixin. Since the slots will all be called at the end of the parent setModel, they shouldn’t be called during the sub-widget’s setModel.

setting_model()