schrodinger.ui.qt.widgetmixins.panelmixins module

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
PRESETS_FEATURE_FLAG = False
classmethod getPanelInstance(create=True)

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

Parameters

create (bool) – Whether to create an instance of the panel if none exists

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.

initSetUp()
initSetDefaults()

@overrides: widgetmixins.InitMixin

show()
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.

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

Bases: schrodinger.ui.qt.widgetmixins.panelmixins.PanelMixin, schrodinger.ui.qt.widgetmixins.basicmixins.StatusBarMixin

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).

A panel task is a task that is launched via the taskbar at the bottom of the panel and generally represents the main purpose of the panel. There may be multiple panel tasks for panels that have more than one mode, and there is always one “active” panel task. The UX for selecting the active task of the panel is determined by each panel, but typically is done with a combobox or set of radio buttons near the top of the panel.

There is a taskmanager for each panel task. The taskmanager handles naming of the tasks and creating a new instance of the panel task each time a panel task is started. The taskmanager also provides access to previously started tasks as well as signals for when any instance of that panel task changes status or finshes.

A panel task’s naming can be customized with setStandardBasename.

The TaskPanelMixin provides a standard taskbar for each panel task; a custom taskbar can be set by overriding _makeTaskBar.

Similarly, a standard config dialog is provided for any panel tasks that are jobtasks. The config dialog may be customized by overriding _makeConfigDialog

TaskPanelMixin persists job settings (accessible through the “Job Settings” item in the gear menu) between sessions. The job settings are saved whenever the config dialog is closed and loaded in initFinalize. The settings are saved using the key PREFERENCES_KEY which defaults to the class name. Subclasses should overwrite PREFERENCES_KEY so the key is stable and unique in case the class name changes or another panel is created with the same name.

DEPENDENCIES: widgetmixins.MessageBoxMixin

Variables

taskWritten – A signal emitted when a task is successfully written. Emits the task instance that was written.

PANEL_TASKS = ()
taskWritten

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

ADD_RESET_THIS_TASK_OPTION = False
initSetUp()
initSetOptions()
initSetDefaults()

@overrides: widgetmixins.InitMixin

initFinalize()
property PREFERENCES_KEY
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. If None is returned, then no actions are set on the settings button.

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 by default,
                      can be enabled by setting the
                      `ADD_RESET_THIS_TASK_OPTION` class variable to
                      True).
  *'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.

Return type

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

setStandardBaseName(base_name, panel_task=None)

Set the base name used for naming tasks.

Parameters
  • base_name (str) – The new base name to use

  • index (tasks.AbstractTask) – The abstract panel task to set the standard basename for. Must be a member of PANEL_TASKS. If not provided, set the basename for the currently active task.

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, 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, Callable]]

setActiveTask(new_active_task)

Set the currently active task. Expects a task from PANEL_TASKS.

Parameters

new_active_task – Abstract task

activeTask()

Return the currently active task.

Returns

The currently active task from PANEL_TASKS

getTask(panel_task=None)

Gets the task instance for a specified panel task. This is the task instance that will be run the next time the corresponding start button is clicked.

Parameters

panel_task – The abstract task from PANEL_TASKS for which to get the next task instance. If None, will return the next task instance for the active task.

getTaskBar(panel_task=None)

Gets the taskbar for a panel task.

Parameters

panel_task – The abstract task from PANEL_TASKS for which to get the taskbar. If None, will return the taskbar for the active panel task.

getTaskManager(panel_task=None)

Gets the taskmanager for a panel task.

Parameters

panel_task – The abstract task from PANEL_TASKS for which to get the taskmanager. If None, will return the taskmanager for the active task.

class schrodinger.ui.qt.widgetmixins.panelmixins.KnimeMixin(*args, _knime_args=None, **kwargs)

Bases: object

A mixin for creating Knime versions of panels. This mixin will hide the taskbars and replace them with an “OK” and “Cancel” button.

All Knime panels _must_ implement panel presets. Generally, subclasses will also implement some behavior to hide widgets that are not relevant to a Knime node as well, though this is not strictly required.

If a Knime panel needs additional arguments, they can be specified through an override of runKnime, passing any additional arguments to the super method as a keyword arguent. All runKnime arguments will be accessible in the instance variable _knime_args dictionary.

If additional initialization logic is needed, subclasses can override initKnime is the last method that’s run during initialization. By default, it will just load the presets file supplied to runKnime.

The “OK” button will attempt to write a task. If a preprocessor fails then an error will show similar to the normal panel. If the preprocessing succeeds, then a job will be written and the settings for the panel will be saved.

If the “Cancel” button is pressed, the panel will just be closed without writing a job or saving settings.

If loading panel settings manually has to be supported for backward compatibility with AF2 framework, subclasses should override loadPanelStateFromNonPresetFile to load non-preset manager generated settings files.

The runKnime static method is the entry point to using Knime panels.

gui_closed

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(*args, _knime_args=None, **kwargs)
initSetOptions()
initFinalize()
initKnime()
loadPanelStateFromNonPresetFile(settings_fname: str, jobname: str)

Override to load state from a non preset manager generated settings file.

Parameters
  • settings_fname (str) – Settings file path.

  • jobname (str) – Job name.

Raises

NotImplementedError – If function is not implemented in subclasses.

closeEvent(event)
classmethod runKnime(*, jobname: str, settings_fname: str, **kwargs)

Call this static method to instantiate this panel in KNIME mode.

Parameters
  • jobname – The basename to save the written job to. The job file will be written as “<jobname>.sh”

  • settings_fname – The filename to use save the settings of the panel. If the settings already exist, then they are used to populate the panel.