schrodinger.ui.qt.structure_selector module

class schrodinger.ui.qt.structure_selector.InputSource(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.Enum

File = 'File'
SelectedEntries = 'Project Table (selected entries)'
IncludedEntries = 'Workspace (included entries)'
IncludedEntry = 'Workspace (included entry)'
class schrodinger.ui.qt.structure_selector.StructureSelectorMaestroSync(*args, **kwargs)

Bases: schrodinger.maestro_utils.maestro_sync.BaseMaestroSync, PyQt6.QtCore.QObject

Variables

projectUpdated – a signal to indicate that the included or selected entries have changed. Emitted with whether Workspace inclusion has changed.

inclusionChanged

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.

selectionChanged

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, **kwargs)
getNumIncludedEntries()
getNumSelectedEntries()
getIncludedStructures()
getSelectedStructures()
inclusionAndSelectionAreIdentical()
class schrodinger.ui.qt.structure_selector.StructureSelectorModel(*args, _param_type=<object object>, **kwargs)

Bases: schrodinger.models.parameters.CompoundParam

Note presence of both file_paths and file_path. These are both included because it’s unclear whether the file selector will be initialized with our without support for multiple files.

If multiple files are supported, StructureSelector.getFilePaths() should be used to access them.

If multiple files are not supported, either StructureSelector.getFilePath() or getFilePaths() may be used to acess the selected file.

sources: List[schrodinger.ui.qt.structure_selector.InputSource]

A Param to represent lists. Values of this param will have a mutated signal that will be emitted whenever any mutation method is called.

The constructor optionally takes a item_class keyword argument to specify what type of class the items in the list will be. This information will be used for jsonifying the list if specified.

current_source: schrodinger.ui.qt.structure_selector.InputSource
source_lbl_text: str

Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:

class Coord(CompoundParam):
    x: int
    y: int

An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:

coord = Coord()
coord.x = 4

When a Param value is set, the valueChanged signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:

class Atom(CompoundParam):
    coord: Coord
    element: str
file_paths: List[str]

A Param to represent lists. Values of this param will have a mutated signal that will be emitted whenever any mutation method is called.

The constructor optionally takes a item_class keyword argument to specify what type of class the items in the list will be. This information will be used for jsonifying the list if specified.

file_path: str

Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:

class Coord(CompoundParam):
    x: int
    y: int

An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:

coord = Coord()
coord.x = 4

When a Param value is set, the valueChanged signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:

class Atom(CompoundParam):
    coord: Coord
    element: str
current_sourceChanged

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.

current_sourceReplaced

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.

file_pathChanged

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.

file_pathReplaced

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.

file_pathsChanged

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.

file_pathsReplaced

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.

source_lbl_textChanged

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.

source_lbl_textReplaced

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.

sourcesChanged

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.

sourcesReplaced

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.

class schrodinger.ui.qt.structure_selector.StructureSelector(parent, sources=None, default_source=None, file_formats=None, support_multiple_files=False, initial_dir=None, browse_button_text=None, id: str | None = None)

Bases: schrodinger.models.mappers.MapperMixin, schrodinger.ui.qt.basewidgets.BaseWidget

Widget to extract structures from maestro and/or files.

model_class

alias of schrodinger.ui.qt.structure_selector.StructureSelectorModel

sourceChanged

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.

inputChanged

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.

FILE_SELECTOR_CLASS

alias of schrodinger.ui.qt.file_selector.FileSelector

__init__(parent, sources=None, default_source=None, file_formats=None, support_multiple_files=False, initial_dir=None, browse_button_text=None, id: str | None = None)

Initialize the StructureSelector.

Parameters
  • parent (QWidget) – Parent widget.

  • sources (List(InputSource)) – Supported input sources. Default is SelectedEntries and File.

  • default_source – Default source. Default is the first source in the “sources” list.

  • file_formats (list) – Supported file formats; see fileutls.py module. E.g. file_formats=[fileutils.MAESTRO].

  • support_multiple_files (bool) – Whether or not to allow the user to select multiple files at once from the file dialog.

  • initial_dir (str) – Initial directory. Default is CWD.

  • browse_button_text (str) – Optional custom text for the file selector browse button

  • id – An identifier to remember the recently browsed directories and show the last browsed directory. Set None (default) to not remember any history.

initSetUp()

Creates widget from ui and stores it ui_widget.

Suggested subclass use: create and initialize subwidgets, and connect signals.

initLayOut()

@overrides: widgetmixins.InitMixin

layoutFileSelector()
createSourceLayout()
showEvent(event)

Enable Maestro callbacks when the panel containing the StructureSelector is shown.

Parameters

event (QShowEvent) – The QEvent object generated by this event.

Returns

The return value of the base class showEvent() method.

hideEvent(event)

Disable Maestro callbacks when the panel containing the StructureSelector is hidden.

Parameters

event (QHideEvent) – The QEvent object generated by this event.

Returns

The return value of the base class hideEvent() method.

defineMappings()

Override this in the subclass to define mappings. Should return a list of tuples [(<target>, <param>)]. Targets can be:

  1. a basic widget, like QLineEdit or QComboBox

  2. a custom object that inherits MapperMixin or TargetMixin

  3. a TargetSpec instance

  4. a slot

For common widgets, standard signals and getter/setter methods will be used, as defined in mappers._get_default_access_names().

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

Supplying a slot as the first element of the tuple is equivalent to providing TargetSpec(slot=my_slot).

Note that all target slots are triggered on setModel() as well as in response to the specified signal.

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),
            (self._onASLTextChanged, MyModel.asl_text)]
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

setInputSourceEnabled(input_source, enable)

Set the combobox item corresponding to input_source enabled/disabled based on whether enable is True/False.

Parameters
  • input_source (InputSource) – input source to enable/disable

  • enable (bool) – whether enable or disable

getFilePath()

Getter for self.model.file_path. Should be used only when certain that multiple file selection is not supported.

Returns

The currently selected input file.

Return type

str

getFilePaths()

Getter for self.model.file_paths or self.model.file_path. Can be used when supporting single or multiple files.

Returns

The currently selected input file(s).

Return type

list(str)

setSourceLabelText(text)
setFileLabelText(text)
inputSource()
setInputSource(source)
widgetStateIsValid()

Validate that the StructureSelector is in a consistent and complete state.

Returns

True if the widget is in a valid state. False otherwise.

Return type

bool

structures()
countStructures()

Return the number of structures specified in the selector.

Returns

The number of structures; or 0 on invalid state.

Return type

int

writeFile(filename)

Writes the selected structures to the given file path.

Parameters

filename – File path

initSetDefaults()

Select the default source.

class schrodinger.ui.qt.structure_selector.ImportButtonMixin

Bases: object

Mixin for adding an “Import” button to the StructureSelector class.

importRequested

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.

initSetUp()
initLayOut()
getSignalsAndSlots(model)
class schrodinger.ui.qt.structure_selector.StructureSelectorWithImportButton(parent, sources=None, default_source=None, file_formats=None, support_multiple_files=False, initial_dir=None, browse_button_text=None, id: str | None = None)

Bases: schrodinger.ui.qt.structure_selector.ImportButtonMixin, schrodinger.ui.qt.structure_selector.StructureSelector

Subclass of StructureSelector that adds an Import button.

class schrodinger.ui.qt.structure_selector.SlimStructureSelector(parent, sources=None, default_source=None, file_formats=None, support_multiple_files=False, initial_dir=None, browse_button_text=None, id: str | None = None)

Bases: schrodinger.ui.qt.structure_selector.StructureSelector

This is a slim version of Structure Selector that spans only one row of widgets. File selection is handled by a single “Browse…” button, and there is no widget for showing the file path. It’s up to individual panels to render the loaded file or entries somewhere in its UI.

To the right of the widget, a “Load” button is present, which gets hidden for File input source. Clicking it causes inputLoaded signal to be emitted. This signal is also emitted when new file is browsed.

To rename the load button:

SlimStructureSelector.load_btn.textText(<name>)

model_class

alias of schrodinger.ui.qt.structure_selector.StructureSelectorModel

inputLoaded

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.

FILE_SELECTOR_CLASS

alias of schrodinger.ui.qt.file_selector.SlimFileSelector

initSetUp()

Creates widget from ui and stores it ui_widget.

Suggested subclass use: create and initialize subwidgets, and connect signals.

initLayOut()

@overrides: widgetmixins.InitMixin

layoutFileSelector()
class schrodinger.ui.qt.structure_selector.StructureLoadButton(*args, **kwargs)

Bases: schrodinger.models.mappers.TargetMixin, schrodinger.ui.qt.basewidgets.BaseWidget

An action combo widget that allows the user to load a structure into its model when an action from the combo menu is selected. Combo menus items are: * “Workspace Entry” -> when triggered will load the Workspace entry into the model. (enable only when exactly one entry is included in the Workspace) * “Selected Entry” -> when triggered will load the selected PT entry into the model. (enable only when exactly one entry is selected in the Workspace) * “File…” -> when triggered will open a file browser dialog, allowing user to select a structure file. First structure from it will be loaded into the model and also imported into the Project Table.

To the right of the combo menu a QLabel is drawn that shows the title of the currently loaded structure. Title will be elided if it’s too long to fit.

initSetUp()

Creates widget from ui and stores it ui_widget.

Suggested subclass use: create and initialize subwidgets, and connect signals.

initLayOut()

Create a vertical layout for the widget (widget_layout) and populate it with two vertical sub-layouts: main_layout and bottom_layout.

If the user has specified the ui data member, insert the resultant ui_widget into main_layout.

If the widget already has a layout defined, this method will produce a warning (but not a traceback). main_layout and bottom_layout will be inserted into the existing widget layout, which will not be the same as widget_layout. It is therefore recommended that this mixin is used only with widgets that do not already have a layout.

Suggested subclass use: create, initialize, and populate layouts.

initSetDefaults()

Clear the loaded structure

setStructure(st)
targetGetValue()
targetSetValue(value)
schrodinger.ui.qt.structure_selector.panel()

For testing StructureSelector widget within Maestro.