schrodinger.ui.qt.appframework2.settings module

class schrodinger.ui.qt.appframework2.settings.SettingsMixin(*args, **kwargs)[source]

Bases: object

Mixin allows an object to save/restore its own state to/from a dictionary. A typical use case would be to collect the values of all the widgets in an options dialog as a dictionary. Example:

dlg = MyOptionsDialog()
saved_settings = dlg.getSettings()
dlg.applySettings(new_settings)

The settings are stored in a dictionary by each widget’s variable name. For widgets that are referenced from within another object, a nested dictionary will be created, the most common example of this being the panel.ui object. A typical settings dictionary may look like this:

{
    'ui': {
            'option_combo': 'Option A',
            'name_le': 'John',
            'remove_duplicate_checkbox': False,
            'num_copies_spinbox': 0
           },
    'other_name_le': 'Job 3'
}

Notice that dictionary keys are the string variable names, not the widgets themselves, and that panel.ui has its own sub-dictionary.

This mixin also supports the concept of aliases, which is a convenient way of accessing objects by a string or other identifier. Example:

self.setAlias(self.ui.my_input_asl_le, 'ASL')
# This is a shortcut for self.getAliasedSetting('ASL')
old_asl = self['ASL']
# This is a shortcut for self.setAliasedSetting('ASL')
self['ASL'] = new_asl

All the information about how to get values from the supported types is found in getObjValue() and setObjValue(). To extend this functionality for more types, either edit these two methods here or override these methods in the derived class, being sure to call the parent method in the else clause after testing for all new types. Always extend both the set and get functionality together.

You can also add support for this mixin to any class by implementing af2SettingsGetValue() and af2SettingsSetValue(). In this way, more complicated widgets or other objects can be automatically discovered.

__init__(*args, **kwargs)[source]
setAlias(alias, obj, persistent=False)[source]

Sets an alias to conveniently access an object.

Parameters
  • alias (hashable) – any hashable, but typically a string name

  • obj (object) – the actual object to be referenced

  • persistent (bool) – whether to make the setting persistent

setAliases(alias_dict, persistent=False)[source]

Sets multiple aliases at once. Already used aliases are overwritten; other existing aliases are not affected.

Parameters
  • alias_dict (dict) – map of aliases to objects

  • persistent (bool) – whether to make the settings persistent

getAliasedSettings()[source]
applyAliasedSettings(settings)[source]

Applies any aliased settings with new values from the dictionary. Any aliases not present in the settings dictionary will be left unchanged.

Parameters

settings (dict) – a dictionary mapping aliases to new values to apply

getAliasedValue(alias)[source]
setAliasedValue(alias, value)[source]
setPersistent(alias=None)[source]

Set options to be persistent. Any options to be made persistent must be aliased, since the alias is used to form the preference key. If no alias is specified, all aliased settings will be made persistent.

Parameters

alias (str or None) – the alias to save, or None

getPersistenceKey(alias)[source]

Return a unique identifier for saving/restoring a setting in the preferences. Override this method to change the key scheme (this is necessary if creating a common resource which is shared by multiple panels).

Parameters

alias (str) – the alias for which we are generating a key

savePersistentOptions()[source]

Store all persistent options to the preferences.

loadPersistentOptions()[source]

Load all persistent options from the preferences.

getSettings(target=None, ignore_list=None)[source]
applySettings(settings, target=None)[source]
getObjValue(obj)[source]
setObjValue(obj, value)[source]
schrodinger.ui.qt.appframework2.settings.get_settings(target, ignore_list=None)[source]

Recursively collects all settings.

Parameters
  • target (object) – the target object from which to collect from. Defaults to self. The target is normally only used in the recursive calls.

  • ignore_list (list of objects) – list of objects to ignore. Also used in recursive calls, to prevent circular reference traversal

Returns

the settings in a dict keyed by reference name. Nested references appear as dicts within the dict.

Return type

dict

schrodinger.ui.qt.appframework2.settings.apply_settings(settings, target)[source]

Recursively applies any settings supplied in the settings argument.

schrodinger.ui.qt.appframework2.settings.get_obj_value(obj)[source]

A generic function for getting the “value” of any supported object. This includes various types of QWidgets, any object that implements an af2SettingsGetValue method, or a tuple consisting of getter and setter functions.

Parameters

obj (object) – the object whose value to get

schrodinger.ui.qt.appframework2.settings.set_obj_value(obj, value)[source]

A generic function for setting the “value” of any supported object. This includes various types of QWidgets, any object that implements an af2SettingsSetValue method, or a tuple consisting of getter and setter functions.

Parameters
  • obj (object) – the object whose value to set

  • value (the type must match whatever the object is expecting) – the value to set the object to

class schrodinger.ui.qt.appframework2.settings.AttributeSettingWrapper(parent_obj, attribute_name)[source]

Bases: object

This allows any object attribute to be treated as a setting. This is useful for mapping an alias to an attribute.

__init__(parent_obj, attribute_name)[source]
af2SettingsGetValue()[source]
af2SettingsSetValue(value)[source]
class schrodinger.ui.qt.appframework2.settings.PanelState(custom_state, auto_state)[source]

Bases: object

A simple container to hold the panel state that is collected by the SettingsPanelMixin. Formerly, the state was held in a simple 2-tuple of (custom_state, auto_state).

__init__(custom_state, auto_state)[source]
class schrodinger.ui.qt.appframework2.settings.SettingsPanelMixin(*args, **kwargs)[source]

Bases: schrodinger.ui.qt.appframework2.settings.SettingsMixin

__init__(*args, **kwargs)[source]
definePanelSettings()[source]

Override this method to define the settings for the panel. The aliased settings provide an interface for saving/restoring panel state as well as for interacting with task/job runners that need to access the panel state in a way that is agnostic to the specifics of widget names and types.

Each panel setting is defined by a tuple that specifies the mapping of alias to panel setting. An optional third element in the tuple can be used to group settings by category. This allows multiple settings to share the same alias.

Each setting can either point to a specific object (usually a qt widget), or a pair of setter/getter functions.

If the mapped object is a string, this will be interpreted by af2 as referring to an attribute on the panel, and a AttributeSettingWrapper instance will automatically be created. For example, specifying the string ‘num_atoms’ will create a mapping to self.num_atoms which will simply get and set the value of that instance member.

Custom setter and getter functions should take the form getter(), returning a value that can be encoded/decoded by JSON, and setter(value), where the type of value is the same as the return type of the getter.

Commonly used objects/widgets should be handled automatically in settings.py. It’s worth considering whether it makes more sense to use a custom setter/getter here or add support for the widget in settings.py.

Returns

a list of tuples defining the custom settings.

Return type

list of tuples. Each tuple can be of type (str, object, str) or (str, (callable, callable), str) where the final str is optional.

Custom settings tuples consists of up to three elements:

  1. alias - a string identier for the setting. Ex. “box_centroid”

  2. either:

    1. an object of a type that is supported by settings.py or

    2. the string name of an existing panel attribute (i.e. member variable), or

    3. a (getter, setter) tuple. The getter should take no arguments, and the setter should take a single value.

  3. optionally, a group identifier. This can be useful if the panel runs two different jobs that both have a parameter with the same name but that needs to map to different widgets. If a setting has a group name, it will be ignored by runners unless the runner name matches the group name.

getPanelState()[source]

Gets the current state of the panel in the form of a serializable dict. The state consists of the settings specified in definePanelSettings() as well as the automatically harvested settings.

setPanelState(state)[source]

Resets the panel and then sets the panel to the specified state

Parameters

state (PanelState) – the panel state to set. This object should originate from a call to getPanelState()

writePanelState(filename=None)[source]

Write the panel state to a JSON file

Parameters

filename (str) – the JSON filename. Defaults to “panelstate.json”

loadPanelState(filename=None)[source]

Load the panel state from a JSON file

Parameters

filename (str) – the JSON filename. Defaults to “panelstate.json”

applyAliasedSettings(settings)

Applies any aliased settings with new values from the dictionary. Any aliases not present in the settings dictionary will be left unchanged.

Parameters

settings (dict) – a dictionary mapping aliases to new values to apply

applySettings(settings, target=None)
getAliasedSettings()
getAliasedValue(alias)
getObjValue(obj)
getPersistenceKey(alias)

Return a unique identifier for saving/restoring a setting in the preferences. Override this method to change the key scheme (this is necessary if creating a common resource which is shared by multiple panels).

Parameters

alias (str) – the alias for which we are generating a key

getSettings(target=None, ignore_list=None)
loadPersistentOptions()

Load all persistent options from the preferences.

savePersistentOptions()

Store all persistent options to the preferences.

setAlias(alias, obj, persistent=False)

Sets an alias to conveniently access an object.

Parameters
  • alias (hashable) – any hashable, but typically a string name

  • obj (object) – the actual object to be referenced

  • persistent (bool) – whether to make the setting persistent

setAliasedValue(alias, value)
setAliases(alias_dict, persistent=False)

Sets multiple aliases at once. Already used aliases are overwritten; other existing aliases are not affected.

Parameters
  • alias_dict (dict) – map of aliases to objects

  • persistent (bool) – whether to make the settings persistent

setObjValue(obj, value)
setPersistent(alias=None)

Set options to be persistent. Any options to be made persistent must be aliased, since the alias is used to form the preference key. If no alias is specified, all aliased settings will be made persistent.

Parameters

alias (str or None) – the alias to save, or None

class schrodinger.ui.qt.appframework2.settings.BaseOptionsPanel(parent=None, **kwargs)[source]

Bases: schrodinger.ui.qt.appframework2.settings.SettingsPanelMixin, schrodinger.ui.qt.appframework2.baseapp.ValidatedPanel

A base class for options dialogs that report all settings via a dictionary. This class descends from ValidatedPanel so it supports all the same validation system, including the @af2.validator decorators.

It shares common code with af2 panels, so setting self.ui, self.title, and self.help_topic all work the same way. It uses the same startup system, so setPanelOptions, setup, setDefaults, and layOut should be used in like fashion.

Appmethods (start, write, custom) are not supported.

To use, instantiate once and keep a reference. Call run() on the instance to open the panel. When the user is done, the panel will either return the settings dictionary (if user clicks ok) or None (if the user clicks cancel).

In place of run(), you may alternatively call open(), which will show the dialog as window modal and return immediately. The settings dictionary may be retrieved using getSettings() or getAliasedSettings().

__init__(parent=None, **kwargs)[source]
Parameters
  • stop_before (int) – Exit the constructor before specified step.

  • parent (QWidget) – Parent widget, if any.

  • in_knime (bool) – Whether we are currently running under KNIME - a mode in which input selector is hidden, optionally a custom Workspace Structure is specified, and buttom bar has OK & Cancel buttons.

  • workspace_st_file (bool) – Structure to be returned by getWorkspaceStructure() when in_knime is True.

setPanelOptions()[source]
setup()[source]

Along with the usual af2 setup actions (instantiating widgets and other objects, connecting signals, etc), this is the recommended place for setting aliases.

setDefaults()[source]
reset()[source]
layOut()[source]
accept()[source]
run()[source]

Show the dialog in modal mode. After dialog is closed, return None if user cancelled, or settings if user accepted.

open()[source]

Open the dialog in window-modal mode, without blocking. This makes it possible for user to interact with the Workspace while dialog is open.

show(self)[source]
reject()[source]
onDialogDismissed()[source]

Override this method with any logic that needs to run when the dialog is dismissed.

help()[source]
property title
DrawChildren = 2
DrawWindowBackground = 1
IgnoreMask = 4
class PaintDeviceMetric

Bases: int

PdmDepth = 6
PdmDevicePixelRatio = 11
PdmDevicePixelRatioScaled = 12
PdmDpiX = 7
PdmDpiY = 8
PdmHeight = 2
PdmHeightMM = 4
PdmNumColors = 5
PdmPhysicalDpiX = 9
PdmPhysicalDpiY = 10
PdmWidth = 1
PdmWidthMM = 3
class RenderFlag

Bases: int

class RenderFlags
class RenderFlags(Union[QWidget.RenderFlags, QWidget.RenderFlag]) None
class RenderFlags(QWidget.RenderFlags) None

Bases: sip.simplewrapper

__init__(*args, **kwargs)
acceptDrops(self) bool
accessibleDescription(self) str
accessibleName(self) str
actionEvent(self, QActionEvent)
actions(self) List[QAction]
activateWindow(self)
addAction(self, QAction)
addActions(self, Iterable[QAction])
adjustSize(self)
applyAliasedSettings(settings)

Applies any aliased settings with new values from the dictionary. Any aliases not present in the settings dictionary will be left unchanged.

Parameters

settings (dict) – a dictionary mapping aliases to new values to apply

applySettings(settings, target=None)
autoFillBackground(self) bool
backgroundRole(self) QPalette.ColorRole
baseSize(self) QSize
blockSignals(self, bool) bool
changeEvent(self, QEvent)
childAt(self, QPoint) QWidget
BaseOptionsPanel.childAt(self, int, int) -> QWidget
childEvent(self, QChildEvent)
children(self) List[QObject]
childrenRect(self) QRect
childrenRegion(self) QRegion
cleanup()
clearFocus(self)
clearMask(self)
close(self) bool
closeEvent(event)

Close panel and quit application if this is a top level standalone window. Otherwise, hide the panel.

colorCount(self) int
connectNotify(self, QMetaMethod)
contentsMargins(self) QMargins
contentsRect(self) QRect
contextMenuEvent(self, QContextMenuEvent)
contextMenuPolicy(self) Qt.ContextMenuPolicy
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
createWindowContainer(QWindow, parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = 0) QWidget
cursor(self) QCursor
customContextMenuRequested

customContextMenuRequested(self, QPoint) [signal]

customEvent(self, QEvent)
definePanelSettings()

Override this method to define the settings for the panel. The aliased settings provide an interface for saving/restoring panel state as well as for interacting with task/job runners that need to access the panel state in a way that is agnostic to the specifics of widget names and types.

Each panel setting is defined by a tuple that specifies the mapping of alias to panel setting. An optional third element in the tuple can be used to group settings by category. This allows multiple settings to share the same alias.

Each setting can either point to a specific object (usually a qt widget), or a pair of setter/getter functions.

If the mapped object is a string, this will be interpreted by af2 as referring to an attribute on the panel, and a AttributeSettingWrapper instance will automatically be created. For example, specifying the string ‘num_atoms’ will create a mapping to self.num_atoms which will simply get and set the value of that instance member.

Custom setter and getter functions should take the form getter(), returning a value that can be encoded/decoded by JSON, and setter(value), where the type of value is the same as the return type of the getter.

Commonly used objects/widgets should be handled automatically in settings.py. It’s worth considering whether it makes more sense to use a custom setter/getter here or add support for the widget in settings.py.

Returns

a list of tuples defining the custom settings.

Return type

list of tuples. Each tuple can be of type (str, object, str) or (str, (callable, callable), str) where the final str is optional.

Custom settings tuples consists of up to three elements:

  1. alias - a string identier for the setting. Ex. “box_centroid”

  2. either:

    1. an object of a type that is supported by settings.py or

    2. the string name of an existing panel attribute (i.e. member variable), or

    3. a (getter, setter) tuple. The getter should take no arguments, and the setter should take a single value.

  3. optionally, a group identifier. This can be useful if the panel runs two different jobs that both have a parameter with the same name but that needs to map to different widgets. If a setting has a group name, it will be ignored by runners unless the runner name matches the group name.

deleteLater(self)
depth(self) int
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
destroyed

destroyed(self, object: QObject = None) [signal]

devType(self) int
devicePixelRatio(self) int
devicePixelRatioF(self) float
devicePixelRatioFScale() float
disconnect(QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
effectiveWinId(self) PyQt5.sip.voidptr
ensurePolished(self)
enterEvent(self, QEvent)
error(text, preferences=None, key='')

Display an error dialog with the specified text. If preferences and key are both supplied, then the dialog will contain a “Don’t show this again” checkbox. Future invocations of this dialog with the same preferences and key values will obey the user’s show preference.

Parameters
  • text (str) – The information to display in the dialog

  • preferences – obsolete; ignored.

  • key (str) – The key to store the preference under. If specified, a “Do not show again” checkbox will be rendered in the dialog box.

Return type

None

event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
find(PyQt5.sip.voidptr) QWidget
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChild(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPolicy(self) Qt.FocusPolicy
focusPreviousChild(self) bool
focusProxy(self) QWidget
focusWidget(self) QWidget
font(self) QFont
fontInfo(self) QFontInfo
fontMetrics(self) QFontMetrics
foregroundRole(self) QPalette.ColorRole
frameGeometry(self) QRect
frameSize(self) QSize
geometry(self) QRect
getAliasedSettings()
getAliasedValue(alias)
getContentsMargins(self) Tuple[int, int, int, int]
getObjValue(obj)
getPanelState()

Gets the current state of the panel in the form of a serializable dict. The state consists of the settings specified in definePanelSettings() as well as the automatically harvested settings.

getPersistenceKey(alias)

Return a unique identifier for saving/restoring a setting in the preferences. Override this method to change the key scheme (this is necessary if creating a common resource which is shared by multiple panels).

Parameters

alias (str) – the alias for which we are generating a key

getSettings(target=None, ignore_list=None)
grab(self, rectangle: QRect = QRect(QPoint(0, 0), QSize(- 1, - 1))) QPixmap
grabGesture(self, Qt.GestureType, flags: Union[Qt.GestureFlags, Qt.GestureFlag] = Qt.GestureFlags())
grabKeyboard(self)
grabMouse(self)
grabMouse(self, Union[QCursor, Qt.CursorShape]) None
grabShortcut(self, Union[QKeySequence, QKeySequence.StandardKey, str, int], context: Qt.ShortcutContext = Qt.WindowShortcut) int
graphicsEffect(self) QGraphicsEffect
graphicsProxyWidget(self) QGraphicsProxyWidget
gui_closed
hasFocus(self) bool
hasHeightForWidth(self) bool
hasMouseTracking(self) bool
hasTabletTracking(self) bool
height(self) int
heightForWidth(self, int) int
heightMM(self) int
hide(self)
hideEvent(self, QHideEvent)
info(text, preferences=None, key='')

Display an information dialog with the specified text. If preferences and key are both supplied, then the dialog will contain a “Don’t show this again” checkbox. Future invocations of this dialog with the same preferences and key values will obey the user’s show preference.

Parameters
  • text (str) – The information to display in the dialog

  • preferences – obsolete; ignored.

  • key (str) – The key to store the preference under. If specified, a “Do not show again” checkbox will be rendered in the dialog box.

Return type

None

inherits(self, str) bool
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
inputMethodHints(self) Qt.InputMethodHints
inputMethodQuery(self, Qt.InputMethodQuery) Any
BaseOptionsPanel.insertAction(self, QAction, QAction)
insertActions(self, QAction, Iterable[QAction])
installEventFilter(self, QObject)
isActiveWindow(self) bool
isAncestorOf(self, QWidget) bool
isEnabled(self) bool
isEnabledTo(self, QWidget) bool
isFullScreen(self) bool
isHidden(self) bool
isLeftToRight(self) bool
isMaximized(self) bool
isMinimized(self) bool
isModal(self) bool
isRightToLeft(self) bool
isSignalConnected(self, QMetaMethod) bool
isVisible(self) bool
isVisibleTo(self, QWidget) bool
isWidgetType(self) bool
isWindow(self) bool
isWindowModified(self) bool
isWindowType(self) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
keyboardGrabber() QWidget
killTimer(self, int)
layout(self) QLayout
layoutDirection(self) Qt.LayoutDirection
leaveEvent(self, QEvent)
loadPanelState(filename=None)

Load the panel state from a JSON file

Parameters

filename (str) – the JSON filename. Defaults to “panelstate.json”

loadPersistentOptions()

Load all persistent options from the preferences.

locale(self) QLocale
logicalDpiX(self) int
logicalDpiY(self) int
lower(self)
mapFrom(self, QWidget, QPoint) QPoint
mapFromGlobal(self, QPoint) QPoint
mapFromParent(self, QPoint) QPoint
mapTo(self, QWidget, QPoint) QPoint
mapToGlobal(self, QPoint) QPoint
mapToParent(self, QPoint) QPoint
mask(self) QRegion
maximumHeight(self) int
maximumSize(self) QSize
maximumWidth(self) int
metaObject(self) QMetaObject
metric(self, QPaintDevice.PaintDeviceMetric) int
minimumHeight(self) int
minimumSize(self) QSize
minimumSizeHint(self) QSize
minimumWidth(self) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseGrabber() QWidget
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
move(self, QPoint)
BaseOptionsPanel.move(self, int, int) -> None
moveEvent(self, QMoveEvent)
moveToThread(self, QThread)
nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) Tuple[bool, int]
nativeParentWidget(self) QWidget
nextInFocusChain(self) QWidget
normalGeometry(self) QRect
objectName(self) str
objectNameChanged

objectNameChanged(self, str) [signal]

overrideWindowFlags(self, Union[Qt.WindowFlags, Qt.WindowType])
overrideWindowState(self, Union[Qt.WindowStates, Qt.WindowState])
paintEngine(self) QPaintEngine
paintEvent(self, QPaintEvent)
paintingActive(self) bool
palette(self) QPalette
parent(self) QObject
parentWidget(self) QWidget
physicalDpiX(self) int
physicalDpiY(self) int
pos(self) QPoint
previousInFocusChain(self) QWidget
property(self, str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

question(msg, button1='OK', button2='Cancel', title='Question')

Display a prompt dialog window with specified text. Returns True if first button (default OK) is pressed, False otherwise.

raise_(self)
receivers(self, PYQT_SIGNAL) int
rect(self) QRect
releaseKeyboard(self)
releaseMouse(self)
releaseShortcut(self, int)
removeAction(self, QAction)
removeEventFilter(self, QObject)
render(self, QPaintDevice, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.RenderFlag.DrawWindowBackground | QWidget.RenderFlag.DrawChildren))
render(self, QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.RenderFlag.DrawWindowBackground | QWidget.RenderFlag.DrawChildren)) None
repaint(self)
BaseOptionsPanel.repaint(self, int, int, int, int) -> None
repaint(self, QRect) None
repaint(self, QRegion) None
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

resize(self, QSize)
BaseOptionsPanel.resize(self, int, int) -> None
resizeEvent(self, QResizeEvent)
restoreCursor(app_wide=True)

Restore the application level cursor to the default. If ‘app_wide’ is True then if will be restored for the entire application, if it’s False, it will be just for this panel.

Parameters

app_wide (bool) – If True then this will restore the cursor for the entire application (including Maestro if running there). If False then this will apply only to this panel.

restoreGeometry(self, Union[QByteArray, bytes, bytearray]) bool
runCanvas()

This handles Canvas-specific logic

runMaestro()

This can be extended in derived classes to perform maestro-only tasks such as setting up the mini-monitor or connecting maestro callbacks

runMode()
runStandalone()
runSubpanel()
runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

saveGeometry(self) QByteArray
savePersistentOptions()

Store all persistent options to the preferences.

BaseOptionsPanel.scroll(self, int, int)
BaseOptionsPanel.scroll(self, int, int, QRect) -> None
sender(self) QObject
senderSignalIndex(self) int
setAcceptDrops(self, bool)
setAccessibleDescription(self, str)
setAccessibleName(self, str)
setAlias(alias, obj, persistent=False)

Sets an alias to conveniently access an object.

Parameters
  • alias (hashable) – any hashable, but typically a string name

  • obj (object) – the actual object to be referenced

  • persistent (bool) – whether to make the setting persistent

setAliasedValue(alias, value)
setAliases(alias_dict, persistent=False)

Sets multiple aliases at once. Already used aliases are overwritten; other existing aliases are not affected.

Parameters
  • alias_dict (dict) – map of aliases to objects

  • persistent (bool) – whether to make the settings persistent

setAttribute(self, Qt.WidgetAttribute, on: bool = True)
setAutoFillBackground(self, bool)
setBackgroundRole(self, QPalette.ColorRole)
BaseOptionsPanel.setBaseSize(self, int, int)
setBaseSize(self, QSize) None
BaseOptionsPanel.setContentsMargins(self, int, int, int, int)
setContentsMargins(self, QMargins) None
setContextMenuPolicy(self, Qt.ContextMenuPolicy)
setCursor(self, Union[QCursor, Qt.CursorShape])
setDisabled(self, bool)
setEnabled(self, bool)
setFixedHeight(self, int)
setFixedSize(self, QSize)
BaseOptionsPanel.setFixedSize(self, int, int) -> None
setFixedWidth(self, int)
setFocus(self)
setFocus(self, Qt.FocusReason) None
setFocusPolicy(self, Qt.FocusPolicy)
setFocusProxy(self, QWidget)
setFont(self, QFont)
setForegroundRole(self, QPalette.ColorRole)
setGeometry(self, QRect)
BaseOptionsPanel.setGeometry(self, int, int, int, int) -> None
setGraphicsEffect(self, QGraphicsEffect)
setHidden(self, bool)
setInputMethodHints(self, Union[Qt.InputMethodHints, Qt.InputMethodHint])
setLayout(self, QLayout)
setLayoutDirection(self, Qt.LayoutDirection)
setLocale(self, QLocale)
setMask(self, QBitmap)
setMask(self, QRegion) None
setMaximumHeight(self, int)
BaseOptionsPanel.setMaximumSize(self, int, int)
setMaximumSize(self, QSize) None
setMaximumWidth(self, int)
setMinimumHeight(self, int)
BaseOptionsPanel.setMinimumSize(self, int, int)
setMinimumSize(self, QSize) None
setMinimumWidth(self, int)
setMouseTracking(self, bool)
setObjValue(obj, value)
setObjectName(self, str)
setPalette(self, QPalette)
setPanelState(state)

Resets the panel and then sets the panel to the specified state

Parameters

state (PanelState) – the panel state to set. This object should originate from a call to getPanelState()

setParent(self, QWidget)
setParent(self, QWidget, Union[Qt.WindowFlags, Qt.WindowType]) None
setPersistent(alias=None)

Set options to be persistent. Any options to be made persistent must be aliased, since the alias is used to form the preference key. If no alias is specified, all aliased settings will be made persistent.

Parameters

alias (str or None) – the alias to save, or None

setProperty(self, str, Any) bool
setShortcutAutoRepeat(self, int, enabled: bool = True)
setShortcutEnabled(self, int, enabled: bool = True)
BaseOptionsPanel.setSizeIncrement(self, int, int)
setSizeIncrement(self, QSize) None
setSizePolicy(self, QSizePolicy)
setSizePolicy(self, QSizePolicy.Policy, QSizePolicy.Policy) None
setStatusTip(self, str)
setStyle(self, QStyle)
setStyleSheet(self, str)
BaseOptionsPanel.setTabOrder(QWidget, QWidget)
setTabletTracking(self, bool)
setToolTip(self, str)
setToolTipDuration(self, int)
setUpdatesEnabled(self, bool)
setVisible(self, bool)
setWaitCursor(app_wide=True)

Set the cursor to the wait cursor. This will be an hourglass, clock or similar. Call restoreCursor() to return to the default cursor.

Parameters

app_wide (bool) – If True then this will apply to the entire application (including Maestro if running there). If False then this will apply only to this panel.

setWhatsThis(self, str)
setWindowFilePath(self, str)
setWindowFlag(self, Qt.WindowType, on: bool = True)
setWindowFlags(self, Union[Qt.WindowFlags, Qt.WindowType])
setWindowIcon(self, QIcon)
setWindowIconText(self, str)
setWindowModality(self, Qt.WindowModality)
setWindowModified(self, bool)
setWindowOpacity(self, float)
setWindowRole(self, str)
setWindowState(self, Union[Qt.WindowStates, Qt.WindowState])
setWindowTitle(self, str)
sharedPainter(self) QPainter
showEvent(show_event)

Override the normal processing when the panel is shown.

showFullScreen(self)
showMaximized(self)
showMinimized(self)
showNormal(self)
signalsBlocked(self) bool
size(self) QSize
sizeHint(self) QSize
sizeIncrement(self) QSize
sizePolicy(self) QSizePolicy
stackUnder(self, QWidget)
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) int
startUp()
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
statusTip(self) str
style(self) QStyle
styleSheet(self) str
tabletEvent(self, QTabletEvent)
testAttribute(self, Qt.WidgetAttribute) bool
thread(self) QThread
timerEvent(self, QTimerEvent)
toolTip(self) str
toolTipDuration(self) int
tr(self, str, disambiguation: str = None, n: int = - 1) str
underMouse(self) bool
ungrabGesture(self, Qt.GestureType)
unsetCursor(self)
unsetLayoutDirection(self)
unsetLocale(self)
update(self)
update(self, QRect) None
update(self, QRegion) None
BaseOptionsPanel.update(self, int, int, int, int) -> None
updateGeometry(self)
updateMicroFocus(self)
updatesEnabled(self) bool
visibleRegion(self) QRegion
warning(text, preferences=None, key='')

Display a warning dialog with the specified text. If preferences and key are both supplied, then the dialog will contain a “Don’t show this again” checkbox. Future invocations of this dialog with the same preferences and key values will obey the user’s show preference.

Parameters
  • text (str) – The information to display in the dialog

  • preferences – obsolete; ignored.

  • key (str) – The key to store the preference under. If specified, a “Do not show again” checkbox will be rendered in the dialog box.

Return type

None

whatsThis(self) str
wheelEvent(self, QWheelEvent)
width(self) int
widthMM(self) int
winId(self) PyQt5.sip.voidptr
window(self) QWidget
windowFilePath(self) str
windowFlags(self) Qt.WindowFlags
windowHandle(self) QWindow
windowIcon(self) QIcon
windowIconChanged

windowIconChanged(self, QIcon) [signal]

windowIconText(self) str
windowIconTextChanged

windowIconTextChanged(self, str) [signal]

windowModality(self) Qt.WindowModality
windowOpacity(self) float
windowRole(self) str
windowState(self) Qt.WindowStates
windowTitle(self) str
windowTitleChanged

windowTitleChanged(self, str) [signal]

windowType(self) Qt.WindowType
writePanelState(filename=None)

Write the panel state to a JSON file

Parameters

filename (str) – the JSON filename. Defaults to “panelstate.json”

x(self) int
y(self) int
schrodinger.ui.qt.appframework2.settings.get_preference_handler()[source]

Gets the af2 global prefence handler. This handler is used for storing persistent settings via this module.

schrodinger.ui.qt.appframework2.settings.get_persistent_value(key, default=<object object>)[source]

Loads a saved value for the given key from the preferences.

Parameters
  • key (str) – the preference key

  • default – the default value to return if the key is not found. If a default is not specified, a KeyError will be raised if the key is not found.

schrodinger.ui.qt.appframework2.settings.set_persistent_value(key, value)[source]

Save a value to the preferences.

Parameters
  • key (str) – the preference key

  • value (any type accepted by the preferences module) – the value to store

schrodinger.ui.qt.appframework2.settings.remove_preference_key(key)[source]

Delete a persistent keypair from the preferences.

Parameters

key (str) – the preference key to remove

schrodinger.ui.qt.appframework2.settings.generate_preference_key(obj, tag)[source]

Automatically generates a preference key based on the given object’s class name, module name, and a string tag.

Since persistant settings are intended to be used across sessions, keys are associated with class definitions, not instances.

Parameters
  • obj (object) – the object (usually a panel) with which the value is associated

  • tag (str) – a string identifier for the piece of data being stored