schrodinger.ui.qt.swidgets module¶
Contains modifications of Qt widgets to allow for easier creation and use, and also general functions for dealing with Qt widgets.
- schrodinger.ui.qt.swidgets.SUP_TEXT(x)¶
- schrodinger.ui.qt.swidgets.SUB_TEXT(x)¶
- class schrodinger.ui.qt.swidgets.SubWidget(label, widget, layout_type)¶
Bases:
tuple
- label¶
Alias for field number 0
- layout_type¶
Alias for field number 2
- widget¶
Alias for field number 1
- class schrodinger.ui.qt.swidgets.SLabel(*args, layout=None, tip=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLabel
A QLabel that can pack itself into a layout upon creation
- __init__(*args, layout=None, tip=None, **kwargs)¶
Create a SLabel instance
- Parameters
layout (QLayout) – layout to place the label in
tip (str) – The tooltip for this label
- reset()¶
Reset the label to its original text
- class schrodinger.ui.qt.swidgets.ElidedLabel(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLabel
Just like a QLabel, except that the text is truncated at the end if it doesn’t fit. Full text is shown in the tooltip.
- __init__(*args, **kwargs)¶
Create a SLabel instance
- Parameters
layout (QLayout) – layout to place the label in
tip (str) – The tooltip for this label
- setText(self, a0: Optional[str])¶
- paintEvent(self, a0: Optional[QPaintEvent])¶
- setElideMode(elide_mode)¶
Set elide mode to Qt.ElideLeft or Qt.ElideRight
- class schrodinger.ui.qt.swidgets.LeftElidedLabel(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.ElidedLabel
Just like a QLabel, except that the text is truncated at the beginning if it doesn’t fit. Full text is shown in the tooltip.
- __init__(*args, **kwargs)¶
Create a SLabel instance
- Parameters
layout (QLayout) – layout to place the label in
tip (str) – The tooltip for this label
- schrodinger.ui.qt.swidgets.elide_rich_text(rich_text: str, font_metrics: PyQt6.QtGui.QFontMetrics, width: int, elide_type=TextElideMode.ElideRight)¶
Using the given width and font metrics, generate the elided text and fit it into the parsed html.
- Parameters
rich_text – the source rich text that needs to be elided
font_metrics – the metrics to calculate the horizontal advance
width – maximum width before cutting off the html with ellipsis
elide_type – where to place the ellipsis
- Returns
new formatted html string to display
- class schrodinger.ui.qt.swidgets.ElidedTextHTMLParser(*args, **kwargs)¶
Bases:
html.parser.HTMLParser
HTML Parser used for parsing rich text and then eliding it given a width and font metrics.
This parser should only be fed single line html.
- class HTMLType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
enum.Enum
- START_TAG = 1¶
- END_TAG = 2¶
- TEXT = 3¶
- __init__(*args, **kwargs)¶
Initialize and reset this instance.
If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.
- handle_starttag(tag, attrs)¶
- handle_endtag(tag)¶
- handle_data(data)¶
- elideRichText(font_metrics: PyQt6.QtGui.QFontMetrics, width: int, elide_type=TextElideMode.ElideRight)¶
Elides the rich text inside the html.
See documentation for
elide_rich_text
.
- class schrodinger.ui.qt.swidgets.ImageLabel(*args, image=None, width=None, height=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLabel
A label that draws an image. High resolution images will be scaled down to the specified size. Works as expected on high resolution (e.g. Retina) displays.
- __init__(*args, image=None, width=None, height=None, **kwargs)¶
Create a label. Optionally specify the image by passing in image, width, and height arguments.
- Parameters
image (QImage) – Image to draw in the label.
width (int or float) – Width to scale down the image to.
height (int or float) – Height to scale down the image to.
- setImage(image, width, height)¶
Set the image to draw, and the dimensions to scale it down to.
- Parameters
image (QImage) – Image to draw in the label.
width (int or float) – Width to scale down the image to.
height (int or float) – Height to scale down the image to.
- setText(self, a0: Optional[str])¶
- paintEvent(event)¶
If an image is set, paint it in the widget. Otherwise, use default paintEvent.
- sizeHint()¶
If an image is set, force the label to be the size of the image.
- sizePolicy()¶
If an image is set, force the label to be fixed size.
- class schrodinger.ui.qt.swidgets.ResizablePictureLabel¶
Bases:
PyQt6.QtWidgets.QLabel
Label that automatically resizes its QPicture as the widget is resized. To keep the aspect ratio, padding is added to top&bottom or left&right sides as needed. To set a background color, use the “background-color” style sheet.
- paintEvent(self, a0: Optional[QPaintEvent])¶
- class schrodinger.ui.qt.swidgets.Spinner(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLabel
A QLabel that shows a rotating spinner icon.
- __init__(*args, **kwargs)¶
Create a Spinner instance.
- startAnimation()¶
Show an animated spinner icon.
- stopAnimation()¶
Stop animation of the spinner icon.
- rotateIcon()¶
- class schrodinger.ui.qt.swidgets.SpinnerIcon(parent=None)¶
Bases:
PyQt6.QtGui.QMovie
Animates a “loading” icon that can be used by any Qt object that has the
setIcon
method.Example:
def startTask(self):
self.button = QtWidgets.QPushButton(‘Button’)
self.loading_icon = bwidgets.SpinnerIcon(self) self.loading_icon.startSpinner(self.button)
self.launchTask()
def taskCallback(self):
self.loading_icon.stopSpinner()
- GIF_FNAME = 'blue-loading.gif'¶
- __init__(parent=None)¶
- startSpinner(qt_obj)¶
Set the
qt_obj
’s icon to a loading icon.- Parameters
qt_obj – Object to set icon for. Must have
setIcon
method.
- cycle()¶
The callback for the
frameChanged
signal. This will grab the pixmap of the current frame and create an icon from it. It then sets theself.qt_obj
’s icon to this icon.
- stopSpinner()¶
Removes the loading icon and sets the object’s icon back to the original icon
- class schrodinger.ui.qt.swidgets.LargeSpinner(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLabel
A QLabel that shows a large rotating spinner icon.
- __init__(*args, **kwargs)¶
- startAnimation()¶
Start the spinner
- stopAnimation()¶
Stop the spinner
- setIcon(icon)¶
For compatibility with the SpinnerIcon class.
- Parameters
icon (QtGui.QIcon or QtGui.QMovie) – Icon to be set
- icon()¶
For compatibility with the SpinnerIcon class.
- class schrodinger.ui.qt.swidgets.SValidIndicator(state=0, layout=None, tips=None)¶
Bases:
schrodinger.ui.qt.swidgets.SLabel
,object
An SLabel that easily changes between a valid icon and an invalid icon
- __init__(state=0, layout=None, tips=None)¶
Create an SValidIndicator instance
- Parameters
state (int) – The initial state of the indicator. Should be one of the module constants INDICATOR_VALID, INDICATOR_INTERMEDIATE, INDICATOR_INVALID
layout (
QtWidgets.QBoxLayout
) – The layout to place the SValidIndicator intips (dict) – The tooltips for the indicator in its various states. Keys should be the possible states (INDICATOR_VALID, etc.) and values should be the corresponding tooltip. Tooltips are optional and may also be provided directly by setState. If no tooltips are provided in either place, the icon will have no tooltip.
- createPixmaps()¶
Create the pixmaps for the indicator states.
- setState(state, tip=None)¶
Set the state of the indicator
- Parameters
state (int) – The new state of the indicator. Should be one of the module constants INDICATOR_VALID, INDICATOR_INTERMEDIATE, INDICATOR_INVALID
tip (str) – The new tooltip for the indicator. If not provided, the tooltips, if any, provided to the constructor will be used.
- Raises
RuntimeError – If no icon corresponds to state
- getState()¶
Get the state of the indicator
- Return type
int
- Returns
The state of the indicator. Will be one of the module constants INDICATOR_VALID, INDICATOR_INTERMEDIATE, INDICATOR_INVALID
- reset()¶
Set the indicator to its initial state
- class schrodinger.ui.qt.swidgets.VerticalLabel(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLabel
This creates a vertical label with property size, position, and enabled/disabled states.
- __init__(*args, **kwargs)¶
Create a label and set default state.
- paintEvent(event)¶
Overwrite parent method. Create a painter with drawn text and tunable colors.
See parent class for additional documentation.
- setEnabled(state)¶
Enable/disable the label by changing the color.
- Parameters
state (bool) – True, if the label widget is enabled.
- minimumSizeHint()¶
Overwrite parent method.
- sizeHint()¶
Overwrite parent method.
- class schrodinger.ui.qt.swidgets.SLineEdit(*args, validator=None, layout=None, width=None, min_width=None, read_only=False, always_valid=False, show_clear=False, show_search_icon=False, placeholder_text=None, tip=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLineEdit
A QLineEdit that accepts a validator as one of its arguments
- AV_ERROR_MSG = 'always_valid must be used in conjuction with a QValidator that has a restoreLastValidValue method.'¶
- __init__(*args, validator=None, layout=None, width=None, min_width=None, read_only=False, always_valid=False, show_clear=False, show_search_icon=False, placeholder_text=None, tip=None, **kwargs)¶
Create a SLineEdit instance. The initial text of this edit will be used by the reset method to reset the SLineEdit.
- Parameters
validator (QValidator) – The validator used for this LineEdit
layout (QLayout) – layout to place the LineEdit in
width (int) – limit on the maximum width of the QLineEdit
min_width (int) – limit on the minimum width of the QLineEdit
read_only (bool) – Whether the edit is read only
always_valid (bool) – If True, the SLineEdit will always restore the last valid value when it loses focus. This prevents blank SLineEdits or SLineEdits with only partially valid values at run time. If False (default), no modification of the SLineEdit value will occur when it loses focus.
show_clear (bool) – Whether to show a clear button in the line edit
show_search_icon (bool) – Whether to show a magnifying glass icon.
placeholder_text (str) – The placeholder text for the edit. This is the text that shows up when the line edit is empty and gives a hint to the user of what to enter.
tip (str) – The tooltip for the label
- setText(text, only_if_valid=False)¶
Set the text of the edit.
- Parameters
text (str) – The text to set in the edit
only_if_valid (bool) – Only set the text if it validates as acceptable via the edit’s validator.
- setToAlwaysValid()¶
Set this instance to always replace invalid text with valid text per validation performed by self.validator
NOTE: The original value is never validated, so we need to set the validator last_valid_value property by hand. Note that forcing a validation here doesn’t work - appears to be a PyQt bug (or feature) where validation doesn’t work inside the __init__method. store it as the last valid value.
- setClearButton(show_clear)¶
This function sets up the clearButton depending on whether the line edit is using it or not. :param show_clear: Whether to show the button or not (at any time) :type show_clear: bool
- resizeEvent(resize_event)¶
This is used to place the clear text button
- updateClearButton(text)¶
Show the clear button if it’s turned on, and the text is non-empty
- reset()¶
Reset the LineEdit to its original text
- float()¶
Returns the current value of the LineEdit as a float
- Return type
float
- Returns
Current float value of the LineEdit
- int()¶
Returns the current value of the LineEdit as a float
- Return type
int
- Returns
Current int value of the LineEdit
- getString()¶
Returns the current value of the LineEdit as a string
- Return type
str
- Returns
The current string value of the LineEdit
- eventFilter(edit, event)¶
Filter FocusOut events so we can restore the last valid value
Note: This could have been done in the event() method rather than eventFilter() method, but doing it this way allows us to NOT process events for line edits that don’t always_valid validity, which saves on overhead.
- Parameters
edit (QWidget) – The widget that generated this event - will be this instance (self)
event (QEvent) – The QEvent object generated by the event
- Return type
bool
- Returns
Whether event processing should stop for this event
- class schrodinger.ui.qt.swidgets.SLabeledEdit(text='', edit_text='', side='left', stretch=True, after_label='', layout=None, tip=None, indicator=False, indicator_state=True, indicator_tips=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLineEdit
An SLineEdit that has a label attached to it.
A SLabledEdit instance has a .label property that is an SLabel widget. The SLabeledEdit instance also has a .mylayout property that the label and edit are placed into. This .mylayout should be added to another layout in order to place the widgets into the GUI if the layout= keyword is not used during construction.
- __init__(text='', edit_text='', side='left', stretch=True, after_label='', layout=None, tip=None, indicator=False, indicator_state=True, indicator_tips=None, **kwargs)¶
Create a SLabeledEdit instance. The initial text of this edit and labels will be used by the reset method to reset the SLineEdit and labels.
- Parameters
text (str) – The text of the label
edit_text (str) – The initial text of the LineEdit
side (str) – ‘left’ if the label should appear to the left of the Line Edit (default), or ‘top’ if the label should appear above it
stretch (bool) – Whether to put a stretch after the LineEdit (or after the after_label). Default is True, even if side=’top’.
after_label (str) – Label text to put after the LineEdit - default is None
layout (QLayout) – layout to place the LabeledEdit in
tip (str) – The tooltip to apply to the labels and edit
indicator (bool) – True if a valid/invalid indicator should be appended
indicator_state (int) – The default state of the indicator (INDICATOR_VALID, INDICATOR_INVALID or INDICATOR_INTERMEDIATE)
indicator_tips (dict) – The tooltips for the different states of the indicator - see the SValidIndicator class for more information
- reset()¶
Reset the label and line edit to their default values
- setEnabled(state)¶
Set all child widgets to enabled state of state
- Parameters
state (bool) – True if widgets should be enabled, False if not
- setVisible(state)¶
Set all child widgets to visible state of state
- Parameters
state (bool) – True if widgets should be visible, False if not
- setIndicator(state, tip=None)¶
Set the state of the indicator icon
- Parameters
state (int) – The new state of the indicator. Should be one of the module constants INDICATOR_VALID, INDICATOR_INTERMEDIATE, INDICATOR_INVALID
tip (str) – The new tooltip for the indicator icon - if not provided, the tooltips, if any, given to the constructor will be used.
- class schrodinger.ui.qt.swidgets.SPushButton(*args, command=None, fixed=True, layout=None, tip=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QPushButton
A QPushButton that accepts the command callback for the clicked() signal as an argument
- __init__(*args, command=None, fixed=True, layout=None, tip=None, **kwargs)¶
Accepts all arguments normally given for a QPushButton
- Parameters
command (function) – function to call when the button emits a ‘clicked()’ signal
fixed (bool) – if True (default), the button horizontal size policy will be ‘fixed’. If false, it will be the QtWidgets.QPushButton default. Otherwise, the horizontal policy will be set to the value given by this parameter.
layout (QLayout) – layout to place the button in
tip (str) – The tooltip for the button
- class schrodinger.ui.qt.swidgets.SCheckBox(*args, command=None, layout=None, checked=False, disabled_checkstate=None, tip=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QCheckBox
A QCheckBox that accepts the command callback for the clicked() signal as an argument
- __init__(*args, command=None, layout=None, checked=False, disabled_checkstate=None, tip=None, **kwargs)¶
Accepts all arguments normally given for a QCheckBox
- Parameters
command (function) – function to call when the checkbox emits a ‘clicked()’ signal
layout (QLayout) – layout to place the CheckBox in
checked (bool) – True if checked to start with, False (default) if not. This is also the state the reset method restores.
disabled_checkstate (bool) – The check state the box should assume when it is disabled. Upon being re-enabled, the box will return to the same state it had prior to being disabled. Calling setChecked() on a disabled box will not actually change the state, but will change the state the box returns to upon being enabled. Use forceSetChecked() to change the current and re-enabled state of a disabled checkbox. The default of None avoids special behavior for disabled checkboxes.
tip (str) – The tooltip for the checkbox
- reset()¶
Reset the checkbox to its initial state
- trackAbleState()¶
Check whether we need to track the checkstate of this widget when it is enabled/disabled
- Return type
bool
- Returns
Whether we should track the checkstate
- changeEvent(event)¶
Overrides the parent method to save & change the checkstate when the widget is enabled/disabled (if requested)
- setChecked(state)¶
Overrides the parent method to not actually change the check state if the widget is disabled AND we’re controlling the checkstate of disabled widgets. In that case, we only store the desired state for when the widget is re-enabled.
- forceSetChecked(state)¶
Change the checkstate of the widget even if it is disabled and we are controlling the checkstate of disabled widgets. Also sets this state to be the state when the widget re-enabled
- Parameters
state (bool) – Whether the checkbox should be checked
- class schrodinger.ui.qt.swidgets.SCheckBoxToggle(*args, nocall=True, command=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SCheckBox
A QCheckBox that accepts the command callback for the toggled() signal as an argument, in comparison to SCheckBox that has command callback bound to clicked() signal.
- __init__(*args, nocall=True, command=None, **kwargs)¶
Accepts all arguments normally given for a QCheckBox
- Parameters
nocall (bool) – True if command should not be called during initialization, False otherwise
command (function) – function to call when the checkbox emits a ‘toggled()’ signal
- class schrodinger.ui.qt.swidgets.SCheckBoxWithSubWidget(text, subwidget, *args, reverse_state=False, hide_disabled=False, layout_type='horizontal', stretch=True, layout=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SCheckBoxToggle
This creates a checkbox that controls the enabled/disabled state of a subwidget. The subwidget can be a single widget or a combination widget such as a frame containing multiple widgets.
The default behavior is to enable the subwidget when the checkbox is checked and disable the widget when the checkbox is unchecked. This behavior can be reversed providing reverse_state=True to the constructor.
- __init__(text, subwidget, *args, reverse_state=False, hide_disabled=False, layout_type='horizontal', stretch=True, layout=None, **kwargs)¶
Create a SCheckBoxWithSubWidget instance.
- Parameters
text (str) – The text label of the checkbox
subwidget (QWidget) – The widget whose enabled state should be controlled by the checkbox
reverse_state (bool) – Default behavior is to set the enabled state of the subwidget to the checked state of the checkbox. Set this parameter to True to set the enabled state of the subwidget to the opposite of the checked state of the checkbox.
hide_disabled (bool) – If True, hide the subwidget when it is disabled. If False, subwidget is greyed out when disabled. Default is False.
layout_type (module constant HORIZONTAL or VERTICAL, or None) – The layout type for the checkbox and subwidget layout. Use None to avoid placing the checkbox and subwidget into a new layout.
stretch (bool) – Whether to add a stretch to the new layout after adding the widgets to it. The default is True if a sublayout is created.
layout (QLayout) – The layout to place the checkbox and subwidget in
Additional arguments can be taken from the SCheckBox class
- setEnabled(state)¶
Set checkbox enabled/disabled state.
- Parameters
state (bool) – the desired state of the checkbox
- setVisible(state)¶
Set both the checkbox and subwidget visible
- Parameters
state (bool) – The desired visible state of both the checkbox and subwidget
- reset()¶
Reset all the widgets
- class schrodinger.ui.qt.swidgets.SCheckBoxEdit(text, *args, checked=False, command=None, disabled_checkstate=None, layout=None, tip=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SCheckBox
A combined checkbox and line edit widget where the checkbox controls the enabled/disabled state of the edit. For use in cases where you want:
[x] some text ______ more text
where [x] is the checkbox and ______ is the line edit and the line edit should be disabled when the checkbox is unchecked.
The parent widget of this widget is the SCheckBox. The widget also contains an SLabeledEdit in the self.edit property and the layout containing both in the self.mylayout property. You can place the widget directly in a layout at creation using the layout keyword argument, or later but adding the .mylayout property to an existing layout.
Attribute requests will be fulfilled by the SCheckBox class first, and then the SLabeledEdit next. Thus, accessing self.isEnabled() will give the enabled state of the checkbox. Accessing self.validator() will give the validator set on the edit. To access an attribute on the edit where the checkbox has an attribute of the same name, you can always use self.edit.attribute.
The exceptions to the attribute hierarchy are the text and setText methods. These give the text and setText methods of the edit, because that is overwhelmingly going to be the widget of interest for those methods. To access the checkbox methods, use checkBoxText and setCheckBoxText methods.
The class constructor can be given keywords for either the SCheckBox or SLabeledEdit class. They will be passed to the proper class.
Note: The first label of the SLabeledEdit is hidden by default, so the ‘some text’ to the edit in the example above should be set as the checkbox label.
- __init__(text, *args, checked=False, command=None, disabled_checkstate=None, layout=None, tip=None, **kwargs)¶
Create a SCheckBoxEdit instance.
Keyword arguments can be taken from the SCheckBox, SLineEdit or SLabeledEdit classes.
- text()¶
Override the checkbox method to get the text from the edit instead. Use checkBoxText to get the checkbox text.
- Return type
str
- Returns
The text contained in the edit
- setText(text)¶
Override the checkbox method to set the text in the edit instead. Use setCeckBoxText to get the checkbox text.
- Parameters
text (str) – The new text for the edit
- checkBoxText()¶
Get the current text of the checkbox label
- Return type
str
- Returns
The text of the checkbox label
- setCheckBoxText(text)¶
Set the text of the checkbox label
- Parameters
text (str) – The new text for the label
- reset()¶
Reset all the widgets
- setEnabled(state)¶
Set both the checkbox and line edit enabled/disabled
- Parameters
state (bool) – The desired enabled state of both the checkbox and edit
- setVisible(state)¶
Set both the checkbox and line edit visible/invisible
- Parameters
state (bool) – The desired visible state of both the checkbox and edit
- static getValuesFromStr(str_in)¶
Helper function for converting from string to bool and text.
- Parameters
str_in (str) – String describing state of the widget
- Return type
(bool, str)
- Returns
Bool is True if checkbox is checked, otherwise - False. Str is edit text value.
- af2SettingsGetValue()¶
This function adds support for the settings mixin. It allows to save checked item states and text in case this combo box is included in a settings panel.
- Returns
String of the form: ‘0_text’, where first number can be 0 or 1 (for the checkbox), ‘text’ is where text from edit goes.
- Return type
str
- af2SettingsSetValue(str_in)¶
This function adds support for the settings mixin. It allows to set combo box check states and edit text when this widget is included in a settings panel.
- Parameters
str_in (str) – String of the form: ‘0_text’, where first number can be 0 or 1 (for the checkbox), ‘text’ is where text from edit goes.
- class schrodinger.ui.qt.swidgets.SRadioButton(*args, command=None, layout=None, checked=False, group=None, tip=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QRadioButton
A QRadioButton that accepts the command callback for the clicked() signal as an argument
- __init__(*args, command=None, layout=None, checked=False, group=None, tip=None, **kwargs)¶
Accepts all arguments normally given for a QRadioButton
- Parameters
command (function) – function to call when the radio button emits a ‘clicked()’ signal
layout (QLayout) – layout to place the RadioButton in
checked (bool) – True if checked to start with, False (default) if not
group (SRadioButtonGroup) – A radio button group to add this button to
tip (str) – The tooltip for this radiobutton
- reset()¶
Reset the radiobutton to its initial state
- class schrodinger.ui.qt.swidgets.SRadioButtonWithSubWidget(subwidget, *args, layout=None, layout_type='horizontal', stretch=True, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SRadioButton
This creates a radio button that controls the enabled/disabled state of a subwidget. The subwidget can be a single widget or a combination widget such as a frame containing multiple widgets.
- __init__(subwidget, *args, layout=None, layout_type='horizontal', stretch=True, **kwargs)¶
- Parameters
subwidget (QWidget) – the widget whose enabled state should be controlled by the radio button
layout (QLayout or None) – the layout to put this widget in if there is one
layout_type (str) – the layout type for the radio button and subwidget, module constant HORIZONTAL or VERTICAL
stretch (bool) – whether to add a stretch to the new layout after adding the widgets to it
- setEnabled(state)¶
Set enabled state.
- Parameters
state (bool) – the desired state
- setVisible(state)¶
Set visible state.
- Parameters
state (bool) – the visible state
- reset()¶
Reset.
- class schrodinger.ui.qt.swidgets.SRadioButtonGroup(parent=None, labels=None, layout=None, command=None, command_clicked=None, nocall=False, default_index=0, tips=None, radio=True, keep_one_checked=False, subwidgets=None)¶
Bases:
PyQt6.QtWidgets.QButtonGroup
A QButtonGroup that accepts the command callback for the buttonClicked() signal as an argument. Also accepts the texts of the radio buttons to create and puts them in the optionally supplied layout.
Button ID’s are the order in which the buttons are created.
- __init__(parent=None, labels=None, layout=None, command=None, command_clicked=None, nocall=False, default_index=0, tips=None, radio=True, keep_one_checked=False, subwidgets=None)¶
Create a SRadioButtonGroup instance
- Parameters
parent (QObject) – the parent object of this ButtonGroup
labels (list) – list of str, the items are the labels of the buttons to create. The ID of each button will be the index of its label in this list.
layout (QLayout) – If supplied, the buttons created will be added to this layout in the order they are created.
command (python callable) – The callback for each button’s toggled(bool) signal
command_clicked (python callable) – The callback for each button’s buttonClicked signal
nocall (bool) – False if the command parameter should be run when setting the default button checked during initialization, True if not
default_index (int) – The button ID (index in the labels list) of the button that should be set checked during initialization. If using checkboxes and no checkbox should be checked, use None.
tips (list) – list of str, the items are tooltips for each button created by the labels list. Must be the same length and in the same order as labels.
radio (bool) – Type of the buttons to use in the group. If True, radio buttons are used, otherwise, checkbox buttons
keep_one_checked (bool) – Only applies if radio=False so that checkboxes are used. If True, as least one checkbox will be enforced checked at all times. If the user unchecks the only checked box, it will immediately be re-checked. Note that any signals that emit when a button changes state will emit when the button is unchecked and then immediately emit again when the button is re-checked.
subwidgets (dict or None) – if a dict then keys are labels and values are instances of SubWidget
- enforceOneChecked(button, state)¶
Ensure that at least one checkbox is checked. If none are checked the toggled checkbox will be set back to checked.
- Parameters
button (QCheckBox) – The button that was toggled and resulted in this slot being called
state – The current state of the checkbox after toggling.
- allCheckedText()¶
Get the text of all the checked boxes. In the case of exclusive radiobuttons, the list will be one item long.
- Return type
list of str
- Returns
Each item is label of a checked box
- addButton(text, connect=True, tip=None, subwidget=None)¶
Create and add a new radio button to the group with the label text.
- Parameters
text (str) – the label for the newly added button
connect (bool) – True if the button should have its toggled(bool) signal connected to the Group’s command property (default), False if not
tip (str) – The tooltip for the button
subwidget (SubWidget or None) – the SubWidget whose enabled state should be controlled by the button
- Return type
int
- Returns
the ID of the new button
- addExistingButton(button, connect=True)¶
Add an existing radio button to the group. The button is not placed in the GroupBox layout.
- Parameters
button (QRadioButton) – The button to add to the group
connect (bool) – True if the button should have its toggled(bool) signal and buttonClicked signal connected to the Group’s command and command_clicked property respectively, False if not
- Return type
int
- Returns
the ID of the new button
- removeButton(button)¶
Remove the button from this group
- Parameters
button (QAbstractButton) – The button to remove
- setTextChecked(text)¶
Check the button with the given text
- Parameters
text (str) – The text of the button to set checked
- Raises
ValueError – If no such button exists
- checkedText()¶
Return the text of the checked button
- Return type
str
- Returns
the text of the checked button
- isChecked(text=None, id=0)¶
Return whether the specified button is checked or not. The button can (must) be specified by either its text label or ID.
- Parameters
text (str) – the label of the button to check
id (int) – the ID of the button to check
- Return type
bool
- Returns
True if the specified button is checked, False if not
- getButtonByText(text)¶
Returns the button with the given text
- Parameters
text (str) – The label of the desired button
- Return type
QRadioButton or None
- Returns
The button with the label text, or None if no such button is found
- reset()¶
Check the default radio button
- setEnabled(state)¶
Set all child buttons to enabled state of state
- Parameters
state (bool) – True if buttons should be enabled, False if not
- setVisible(state)¶
Set the visibility of all child buttons
- Parameters
state (bool) – Whether the widgets should be visible
- setExclusive(state, uncheckable=False)¶
Uncheck all the buttons except the button clicked
- Parameters
state (bool) – True if buttons should be exclusive and uncheckable. False if its not exclusive.
uncheckable (bool) – If true, when setExclusive is true it will allow to deselect the selected option. Won’t have any effect if setExclusive is False, since uncheckability is already allowed in that case. if False, the function behaves like the usual setExclusive function.
- checkState(button)¶
Uncheck all the buttons except the button clicked
- Parameters
button (QCheckBox or QRadioButton) – The button that was clicked
- class schrodinger.ui.qt.swidgets.SLabeledRadioButtonGroup(group_label=None, layout_type='horizontal', layout=None, stretch=True, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SRadioButtonGroup
Convenience class for adding all SRadioButtonGroup buttons to a layout with an optional group label
- __init__(group_label=None, layout_type='horizontal', layout=None, stretch=True, **kwargs)¶
Create an instance.
- Parameters
group_label (str) – The label for the button group
layout_type (str) – Module constants VERTICAL or HORIZONTAL for the type of internal layout
layout (QLayout) – The layout to add the internal layout to
stretch (bool) – Whether to add a stretch after the last button
- setEnabled(state)¶
Set the enabled state of radio buttons and group label
- Parameters
state (bool) – Whether the widgets should be enabled
- setVisible(state)¶
Set the visibility of all child buttons and group label
- Parameters
state (bool) – Whether the widgets should be visible
- reset()¶
Reset radio buttons and group label
- schrodinger.ui.qt.swidgets.set_layout_margins(layout, indent=False)¶
Sets all layout margins to be 0, with the possible exception of indenting the left margin.
- Parameters
layout (QBoxLayout) – The layout to set the margins on
indent (bool or int) – False for a 0 left margin, True for a STANDARD_INDENT left margin, or an int for the value of the left margin
- class schrodinger.ui.qt.swidgets.SHBoxLayout(*args, indent=False, layout=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QHBoxLayout
A QHBoxLayout with the proper margins for Schrodinger layouts.
- __init__(*args, indent=False, layout=None, **kwargs)¶
Accepts all arguments normally given for a QHBoxLayout
- Parameters
indent (bool or int) – False for a 0 left margin, True for a STANDARD_INDENT left margin, or an int for the value of the left margin - False by default.
layout (QBoxLayout) – The layout this layout should be placed in
- class schrodinger.ui.qt.swidgets.SVBoxLayout(*args, indent=False, layout=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QVBoxLayout
A QVBoxLayout with the proper margins for Schrodinger layouts.
- __init__(*args, indent=False, layout=None, **kwargs)¶
Accepts all arguments normally given for a QVBoxLayout
- Parameters
indent (bool or int) – False for a 0 left margin, True for a STANDARD_INDENT left margin, or an int for the value of the left margin - False by default.
layout (QBoxLayout) – The layout this layout should be placed in
- class schrodinger.ui.qt.swidgets.SGridLayout(*args, indent=False, layout=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QGridLayout
A QGridLayout with the proper margins for Schrodinger layouts
- __init__(*args, indent=False, layout=None, **kwargs)¶
Accepts all arguments normally given for a QGridLayout
- Parameters
indent (bool or int) – False for a 0 left margin, True for a STANDARD_INDENT left margin, or an int for the value of the left margin - False by default.
layout (QBoxLayout) – The layout this layout should be placed in
- class schrodinger.ui.qt.swidgets.SGroupBox(*args, layout_type=None, parent_layout=None, checkable=False, checked=True, tip=None, flat=False, command=None, toggled_command=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QGroupBox
A QGroupBox that includes a layout with the proper margins and spacing for Schrodinger layouts. By default, this is a vertical layout.
- __init__(*args, layout_type=None, parent_layout=None, checkable=False, checked=True, tip=None, flat=False, command=None, toggled_command=None, **kwargs)¶
Accepts all arguments normally given for a QGroupBox
- Parameters
layout_type (string) – Module constants VERTICAL, HORIZONTAL or GRID, for the type of internal layout
parent_layout (QBoxLayout) – The layout to place this SGroupBox into
checkable (bool) – Whether the groupbox is checkable, False by default
checked (bool) – Whether the groupbox should be checked if checkable. Default is True for checkable groupboxes.
tip (str) – The tooltip to apply to the group box
flat (bool) – whether to apply FlatStyle
command (function) – function to call when the checkbox emits a ‘clicked()’ signal
toggled_command (function) – function to call when the checkbox emits a ‘toggled()’ signal
- reset()¶
Reset the GroupBox to the default check state if checkable
- class schrodinger.ui.qt.swidgets.SNoCommaMinMaxMixin¶
Bases:
object
This is a mixin class to bound value to top and bottom. It validates the absence of comma in the input. Further, it will validate whether the value is in between min and max.
Custom Validation classes can inherit from this class first, then the base Validator class. i.e. class MyValidator(SNoCommaMinMaxMixin, QtGui.QIntValidator):
- minMaxValidate(value, pos, datatype=<class 'float'>, bottom=-inf, top=inf)¶
Method is a validator
- Parameters
value (int or float) – any int or float data to be validated
pos (int) – position of the cursor
datatype (type) – datatype of value, Default is float
bottom (int or float) – minimum value
top (int or float) – maximum value
- Return type
tuple
- Returns
tuple of QtValidator definition of valid, value and pos. See PyQt QValidator documentation for definition of valid.
- class schrodinger.ui.qt.swidgets.EnforcingValidatorMixin¶
Bases:
object
This is a mixin class to be added to a QValidator subclass. It tracks the last valid value for a QLineEdit and can restore it when asked. Adding this mixin to a QValidator subclass will automatically enable it to work with the SLineEdit class “always_valid” parameter.
Custom Validation classes should inherit from this class first, then the base Validator class. i.e. class MyValidator(EnforcingValidatorMixin, QtGui.QIntValidator):
If a custom class overwrites the validate method, that method must store valid strings in self.last_valid_value before returning self.Acceptable.
- restoreLastValidValue(edit)¶
Restores edit to the last valid value validated by this Validator
- Parameters
edit (QLineEdit) – The QLineEdit to restore the value to
- validate(*args)¶
Validate, and store the current value if it is valid
See PyQt documentation for argument and return value documentation.
If a custom class overwrites the validate method, that method must store valid strings in self.last_valid_value before returning self.Acceptable.
- class schrodinger.ui.qt.swidgets.FileBaseNameValidator(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,PyQt6.QtGui.QValidator
Manage a file base name validator.
- __init__(*args, **kwargs)¶
- validate(value, position)¶
See PyQt documentation for arguments and return values.
- class schrodinger.ui.qt.swidgets.SAsciiOnlyValidator¶
Bases:
PyQt6.QtGui.QValidator
Ensures that the line edit contains only ASCII characters
- validate(value, position)¶
Do not accept strings that can’t be converted to type ‘str’
See PyQt documentation for argument and return value documentation.
- class schrodinger.ui.qt.swidgets.SASLValidator¶
Bases:
PyQt6.QtGui.QValidator
Ensures that the line edit contains valid ASL
- validate(value, position)¶
Mark not valid ASL strings as intermediate.
- class schrodinger.ui.qt.swidgets.SNonEmptyStringValidator(parent=None)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,PyQt6.QtGui.QValidator
A QValidator that ensures that only accepts non-empty strings and can enforce validity if the validated widget loses focus and is empty. Unicode characters are not accepted.
- __init__(parent=None)¶
Create an SNonEmptyStringValidator object
- Parameters
parent (QObject) – the object that owns the validator
bottom (float) – the least positive/most negative number accepted
top (float) – the most positive/least negative number accepted. If top=None, then there is no limit at the top end of the scale.
- validate(value, position)¶
We only want to accept non-empty strings. Empty strings are considered Intermediate as this allows the edit to be cleared.
See PyQt documentation for argument and return value documentation.
- class schrodinger.ui.qt.swidgets.SNoCommaDoubleValidator¶
Bases:
schrodinger.ui.qt.swidgets.SNoCommaMinMaxMixin
,PyQt6.QtGui.QDoubleValidator
A double validator that does not accept comma, which is used and accepted as a group separator in QDoubleValidator.
- validate(self, a0: Optional[str], a1: int)¶
- class schrodinger.ui.qt.swidgets.SRealValidator(parent=None, bottom=None, top=None, decimals=None)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,schrodinger.ui.qt.swidgets.SNoCommaDoubleValidator
A QValidator that only accepts real numbers and can enforce validity if the validated widget loses focus and does not have valid text.
- __init__(parent=None, bottom=None, top=None, decimals=None)¶
- Parameters
parent (QObject) – the object that owns the validator
bottom (float) – the least positive/most negative number accepted
top (float) – the most positive/least negative number accepted. If top=None, then there is no limit at the top end of the scale.
decimals (int) – Maximum number of digits after the deciaml point. If decimals is None, default decimals from QDoubleValidator (1000) is used.
- class schrodinger.ui.qt.swidgets.SNonNegativeRealValidator(parent=None, bottom=0.0, top=None, decimals=None)¶
Bases:
schrodinger.ui.qt.swidgets.SRealValidator
A QValidator that only accepts non-negative (0.0 to +infinity) real numbers and can enforce validity if the validated widget loses focus and does not have valid text.
- __init__(parent=None, bottom=0.0, top=None, decimals=None)¶
- Parameters
parent (QObject) – the object that owns the validator
bottom (float) – the least positive/most negative number accepted
top (float) – the most positive/least negative number accepted. If top=None, then there is no limit at the top end of the scale.
decimals (int) – Maximum number of digits after the decimal point. If decimals is None, default decimals from QDoubleValidator (1000) is used.
- class schrodinger.ui.qt.swidgets.SNoCommaIntValidator¶
Bases:
schrodinger.ui.qt.swidgets.SNoCommaMinMaxMixin
,PyQt6.QtGui.QIntValidator
An int validator that does not accept comma, which is used and accepted as a group separator in QIntValidator.
- validate(self, a0: Optional[str], a1: int)¶
- class schrodinger.ui.qt.swidgets.SNonNegativeIntValidator(parent=None, bottom=0, top=None)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,schrodinger.ui.qt.swidgets.SNoCommaIntValidator
A QValidator that only accepts non-negative (0 to +infinity) int numbers and can enforce validity if the validated widget loses focus and does not have valid text.
- __init__(parent=None, bottom=0, top=None)¶
- Parameters
parent (QObject) – the object that owns the validator
bottom (int) – the least positive/most negative number accepted
top (int) – the most positive/least negative number accepted. If top=None, then there is no limit at the top end of the scale.
- class schrodinger.ui.qt.swidgets.SNumberListValidator(parent=None, delimiter=None, number_type=<class 'int'>, bottom=0)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,PyQt6.QtGui.QValidator
A Validator that only accepts a list of numbers (int or floats) with a delimiter. Minimum accepted number can be defined in ‘bottom’ parameter.
- __init__(parent=None, delimiter=None, number_type=<class 'int'>, bottom=0)¶
Create a SNumberListValidator object.
- Parameters
delimiter (str) – The delimiter for the list of numbers. If not given, any whitespace is considered a delimiter
number_type (type (int or float allowed)) – Type to convert to, int or float
bottom (int or float) – the least positive/most negative number accepted
See parent class for additional documentation
- validate(value, position)¶
Only accept a list of comma-delimited positive integers
See PyQt documentation for argument and return value documentation.
- class schrodinger.ui.qt.swidgets.SPosIntListValidator(parent=None, delimiter=None)¶
Bases:
schrodinger.ui.qt.swidgets.SNumberListValidator
A Validator that only accepts a list of positive ints with a delimiter.
- __init__(parent=None, delimiter=None)¶
Create a PosIntListValidator object
- Parameters
delimiter (str) – The delimitor for the list of ints. If not given, any whitespace is considered a delimiter
See parent class for additional documentation
- class schrodinger.ui.qt.swidgets.SRegularExpressionValidator(regexp: PyQt6.QtCore.QRegularExpression, parent: PyQt6.QtCore.QObject = None)¶
Bases:
schrodinger.ui.qt.swidgets.EnforcingValidatorMixin
,PyQt6.QtGui.QRegularExpressionValidator
A validator that only accepts strings that match the regexp.
- __init__(regexp: PyQt6.QtCore.QRegularExpression, parent: PyQt6.QtCore.QObject = None)¶
Create an SRegularExpressionValidator object.
- Parameters
regexp – Regular expression to validate
parent – the object that owns the validator
- class schrodinger.ui.qt.swidgets.SComboBox(parent=None, items=None, default_item='', default_index=0, command=None, nocall=False, layout=None, tip='', itemdict=None, adjust_to_contents=True, min_width=None)¶
Bases:
PyQt6.QtWidgets.QComboBox
A QComboBox widget with several Pythonic enhancements. It can also set its items and select a default value at creation time; and can be easily reset to its default value via reset.
A slot can be specified that will be hooked up with the currentIndexChanged[str] signal. This command will be called when the default value is set unless nocall=True
Action items can be added via the addAction() method. These items are not selectable. When one is chosen, its callback is executed and previously selected item is re-selected.
- currentIndexChanged¶
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__(parent=None, items=None, default_item='', default_index=0, command=None, nocall=False, layout=None, tip='', itemdict=None, adjust_to_contents=True, min_width=None)¶
Create an SComboBox object.
- Parameters
parent (QWidget) – The parent widget of this SComboBox
items (list) – list of items (str) to be added to the ComboBox - see also itemdict.
default_item (str) – text of the item to select initially and upon reset
default_index (int) – the index of the item to select initially and upon reset. default_item overrides this parameter.
command (callable) – The slot to connect to the currentIndexChanged[str] signal. This command will be called when the default item is selected during initialization unless nocall=True.
nocall (bool) – True if command should not be called during initialization, False otherwise
layout (QLayout) – The layout to place this widget in
tip (str) – The tooltip for the combo
itemdict (
collections.OrderedDict
) – An OrderedDictionary with ComboBox items as keys and data as values. The data for the current ComboBox item is returned by the currentData method. If both items and itemdict are given, items are added first.adjust_to_contents (bool) – True if the size adjust policy should be set to “Adjust to contents”
min_width (int) – this property holds the minimum number of characters that should fit into the combobox
- addItemsFromDict(items)¶
Add items to the combo box from a dictionary of {text: user_data}. Note that setting the order of elements requires a
collections.OrderedDict
- Parameters
items (dict) – A dictionary of {text: user_data} to add to the combo box
- currentData(role=ItemDataRole.UserRole)¶
Get the user data for the currently selected item
- Parameters
role (int) – The role to retrieve data for
- Returns
The user data
- setCurrentData(data, role=ItemDataRole.UserRole)¶
Select the index with the specified user data
- Parameters
text – The user data to select
role (int) – The role to search
- Raises
ValueError – If the specified data is not found in the combo box
- findData(data, role=ItemDataRole.UserRole)¶
Get the index of the item containing the specified data. Comparisons are done in Python rather than in C++ (as they are in
QComboBox.findData
) so that Python types without a direct C++ mapping can be compared correctly. Seeqt_utils.combo_find_data_py
for additional documentation.- Parameters
data (object) – The data to search for
role (Qt.ItemDataRole) – The role to search
- findDataPy(data, role=ItemDataRole.UserRole)¶
Get the index of the item containing the specified data. Similar to
findData
, but aValueError
will be raised if the specified data cannot be found. (findData
mimics theQComboBox.findData
behavior and returns a-1
in that scenario.)See
findData
documentation for parameter documentation.
- reset()¶
Reset the current ComboBox item to the default item.
- setCurrentText(text)¶
Set the combobox to the item with the supplied text
- Parameters
text (str) – The text of the item to make the current item
- Raise
ValueError if no item with text exists
- addItem(*args, **kwargs)¶
Add given items and emit signals as needed.
- addItems(*args, **kwargs)¶
Add given items and emit signals as needed.
- addAction(text, callback)¶
Add an “action” menu item. When selected by the user, it will invoke the callback and re-select the previously selected item.
- setCurrentIndex(self, index: int)¶
- keyPressEvent(event)¶
Ignore Up/Down key press events if any action items are present. In the future, consider re-implementing these handlers; it’s a non- trivial task. See http://code.metager.de/source/xref/lib/qt/src/gui/widgets/qcombobox.cpp#2931
- items()¶
Return the current list of items in the combo box.
- Return type
list
- Returns
the current list of items
- enableItems(texts=None, enable=True)¶
Enable/disable item in combo box based on texts :param list texts: list of item text to be enabled or disabled :param bool enable: Enable or disable item
- enableAllItems(enable=True)¶
Enable/disable all item in combobox
- Parameters
enable (bool) – Enable or disable item
- removeItemByText(text)¶
Removes the item with the given text
- Parameters
text (str) – the text of the item to be removed
- Return type
bool
- Returns
True if an item was removed, False otherwise
- class schrodinger.ui.qt.swidgets.SLabeledComboBox(text, side='left', stretch=True, after_label='', layout=None, tip='', **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SComboBox
An SComboBox that has a label attached to it.
A SLabeledComboBox instance has a .label property that is an SLabel widget. The SLabeledComboBox instance also has a .mylayout property that the label and ComboBox are placed into. This .mylayout should be added to another layout in order to place the widgets into the GUI if the layout= keyword is not used during construction.
- __init__(text, side='left', stretch=True, after_label='', layout=None, tip='', **kwargs)¶
Create a SLabledComboBox instance
- Parameters
text (str) – The text of the label
side (str) – ‘left’ if the label should appear to the left of the ComboBox (default), or ‘top’ if the label should appear above it
stretch (bool) – Whether to put a stretch after the ComboBox (or after the after_label). Default is True, even if side=’top’.
after_label (str) – Label text to put after the ComboBox - default is None
layout (QLayout) – layout to place the LabeledEdit in
tip (str) – The tooltip for the labels and combobox
- mylayout¶
Place this layout into the parent GUI, not the ComboBox
- reset()¶
Reset the labels and ComboBox to their default values
- setEnabled(state)¶
Set all child widgets to enabled state of state
- Parameters
state (bool) – True if widgets should be enabled, False if not
- setVisible(state)¶
Set all child widgets to visible state of state
- Parameters
state (bool) – True if widgets should be visible, False if not
- class schrodinger.ui.qt.swidgets.ActionComboBox(parent, text='')¶
Bases:
PyQt6.QtWidgets.QComboBox
A combo box with a few notable changes:
“action” signal is emitted when a new item is selected, and callback is called when one is provided for the selected menu.
The label of the combo box never changes - there is no concept of a currently selected item.
The label of the combo box is not shown in the pop-up menu.
For custom behavior (e.g. disabling items), use the ActionComboBox.menu attribute to get the QMenu object.
- Parameters
itemSelected (
PyQt5.QtCore.pyqtSignal
) – signal emitted when a menu item is selected. The only argument is the text of the selected item.
- itemSelected¶
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__(parent, text='')¶
- Parameters
text – Text/label to show in the combo menu. This is what the user sees until they click on the widget.
text – str
- addItem(text, callback=None)¶
Add a menu item with the given action callback. When this item is selected, the specified callback will be called in addition to emitting the itemSelected signal.
- addAction(self, icon: QIcon, text: Optional[str]) Optional[QAction] ¶
- addAction(self, icon: QIcon, text: Optional[str], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, icon: QIcon, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int]) Optional[QAction]
- addAction(self, icon: QIcon, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, text: Optional[str]) Optional[QAction]
- addAction(self, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int]) Optional[QAction]
- addAction(self, text: Optional[str], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, action: Optional[QAction]) None
- addSeparator()¶
- count(self) int ¶
- setText(combo_txt)¶
Sets texts that will be shown in combo box label widget.
- Parama combo_txt
combo box default text
- reset()¶
- showPopup(self)¶
- actionTriggered(action)¶
This function is called when item is selected in the popup.
- Parameters
item_index (int) – Index (position) of the selected menu item.
- class schrodinger.ui.qt.swidgets.ActionPushButton(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QPushButton
A push button that pops-up a menu when clicked. Similar to ActionComboBox except that there is no concept of selection / current item.
- icon = '/scr/buildbot/savedbuilds/2024-4/NB/build-117/internal/lib/python3.11/site-packages/schrodinger/ui/qt/pushbutton-menu-arrow.png'¶
- platform_specific = 'width: 13px;'¶
- STYLE_SHEET = '\n QPushButton::menu-indicator {\n image: url("/scr/buildbot/savedbuilds/2024-4/NB/build-117/internal/lib/python3.11/site-packages/schrodinger/ui/qt/pushbutton-menu-arrow.png");\n subcontrol-position: center right;\n subcontrol-origin: padding;\n width: 13px;\n }\n '¶
- __init__(*args, **kwargs)¶
- addItem(text, function)¶
- addAction(self, icon: QIcon, text: Optional[str]) Optional[QAction] ¶
- addAction(self, icon: QIcon, text: Optional[str], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, icon: QIcon, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int]) Optional[QAction]
- addAction(self, icon: QIcon, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, text: Optional[str]) Optional[QAction]
- addAction(self, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int]) Optional[QAction]
- addAction(self, text: Optional[str], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, text: Optional[str], shortcut: Union[QKeySequence, QKeySequence.StandardKey, Optional[str], int], slot: PYQT_SLOT, type: Qt.ConnectionType = Qt.AutoConnection) Optional[QAction]
- addAction(self, action: Optional[QAction]) None
- addSeparator()¶
- class schrodinger.ui.qt.swidgets.MinMaxSpinBoxTether(minbox, maxbox, parent=None, delta=0)¶
Bases:
PyQt6.QtCore.QObject
A QObject that ties two spinboxes together and ensures that the max spinbox never has a value less than the min spinbox. This restriction is enforced when one of the spinbox changes by changing the value of the other spinbox if necessary.
- __init__(minbox, maxbox, parent=None, delta=0)¶
Create a MinMaxSpinboxTether object
- Parameters
minbox (QSpinBox) – The spinbox controlling the minimum value
maxbox (QSpinBox) – The spinbox controlling the maximum value
parent (QWidget) – The parent widget
delta (int or float) – The minimum value by which the two spinboxes must differ - i.e. a value of 1 means the minimum spinbox must always be at least 1 less than the maximum spinbox
- minimumChanged()¶
React to a change in the minimum value
- maximumChanged()¶
React to a change in the maximum value
- class schrodinger.ui.qt.swidgets.SSpinBox(parent=None, minimum=None, maximum=None, value=None, layout=None, command=None, nocall=False, stepsize=None, width=None, tip=None)¶
Bases:
PyQt6.QtWidgets.QSpinBox
A QSpinBox that can set it’s min, max and value in the constructor plus pack itself in a layout
- __init__(parent=None, minimum=None, maximum=None, value=None, layout=None, command=None, nocall=False, stepsize=None, width=None, tip=None)¶
Create an SSpinBox object
- Parameters
parent (QObject) – the parent object of this SSpinBox
minimum (int) – The minimum value of this SSpinBox
maximum (int) – The maximum value of this SSpinBox
value (int) – The initial value of this SSpinBox. This value will also be used as the default value by the reset method.
layout (QLayout) – If supplied, the SSpinBox created will be added to this layout
command (python callable) – The callback for the valueChanged signal. This command will not be called during initialization unless nocall is set to False.
nocall (bool) – True if the callback command should not be called during initialization, False (default) if the command should be called.
stepsize (int) – The stepsize each arrow click changes the value by
width (int) – The maximum width of the spinbox
tip (str) – The tooltip
- reset()¶
Reset the spin box to its default value
- class schrodinger.ui.qt.swidgets.SDoubleSpinBox(parent=None, minimum=None, maximum=None, value=None, layout=None, command=None, nocall=False, stepsize=None, decimals=None, width=None, tip=None)¶
Bases:
PyQt6.QtWidgets.QDoubleSpinBox
A QDoubleSpinBox that can set it’s min, max and value in the constructor plus pack itself in a layout
- __init__(parent=None, minimum=None, maximum=None, value=None, layout=None, command=None, nocall=False, stepsize=None, decimals=None, width=None, tip=None)¶
Create an SDoubleSpinBox object
- Parameters
parent (QObject) – the parent object of this SDoubleSpinBox
minimum (float) – The minimum value of this SDoubleSpinBox
maximum (float) – The maximum value of this SDoubleSpinBox
value (float) – The initial value of this SDoubleSpinBox. This value will also be used as the default value by the reset method.
stepsize (float) – The stepsize each arrow click changes the value by
decimals (int) – Number of decimal places to display
layout (QLayout) – If supplied, the SDoubleSpinBox created will be added to this layout
command (python callable) – The callback for the valueChanged signal. This command will be called during initialization unless nocall is set to True.
nocall (bool) – True if the callback command should not be called during initialization, False (default) if the command should be called.
width (int) – The maximum width of the spinbox
tip (str) – The tooltip
- reset()¶
Reset the spin box to its default value
- class schrodinger.ui.qt.swidgets.SLabeledDoubleSpinBox(text, side='left', stretch=True, after_label='', layout=None, tip=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SDoubleSpinBox
An SDoubleSpinBox that has a label attached to it.
A SLabledDoubleSpinBox instance has a .label property that is an SLabel widget. The SLabeledComboBox instance also has a .mylayout property that the label and SDoubleSpinBox are placed into. This .mylayout should be added to another layout in order to place the widgets into the GUI if the layout= keyword is not used during construction.
- __init__(text, side='left', stretch=True, after_label='', layout=None, tip=None, **kwargs)¶
Create a SLabledDoubleSpinBox instance
- Parameters
text (str) – The text of the label
side (str) – ‘left’ if the label should appear to the left of the SDoubleSpinBox (default), or ‘top’ if the label should appear above it
stretch (bool) – Whether to put a stretch after the SDoubleSpinBox (or after the after_label). Default is True, even if side=’top’.
after_label (str) – Label text to put after the SDoubleSpinBox - default is None
layout (QLayout) – If supplied, the SDoubleSpinBox created will be added to this layout
tip (str) – The tooltip to apply to the labels and spinbox
- mylayout¶
Place this layout into the parent GUI, not the ComboBox
- reset()¶
Reset the labels and ComboBox to their default values
- setEnabled(state)¶
Set all child widgets to enabled state of state
- Parameters
state (bool) – True if widgets should be enabled, False if not
- setVisible(state)¶
Set all child widgets to visible state of state
- Parameters
state (bool) – True if widgets should be visible, False if not
- class schrodinger.ui.qt.swidgets.SLabeledSpinBox(text, side='left', stretch=True, after_label='', layout=None, tip='', **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SSpinBox
An SSpinBox that has a label attached to it.
A SLabledSpinBox instance has a .label property that is an SLabel widget. The SLabeledSpinBox instance also has a .mylayout property that the label and SSpinBox are placed into. This .mylayout should be added to another layout in order to place the widgets into the GUI if the layout= keyword is not used during construction.
- __init__(text, side='left', stretch=True, after_label='', layout=None, tip='', **kwargs)¶
Create a SLabledSpinBox instance
- Parameters
text (str) – The text of the label
side (str) – ‘left’ if the label should appear to the left of the SSpinBox (default), or ‘top’ if the label should appear above it
stretch (bool) – Whether to put a stretch after the SSpinBox (or after the after_label). Default is True, even if side=’top’.
after_label (str) – Label text to put after the SSpinBox - default is None
layout (QLayout) – If supplied, the SSpinBox created will be added to this layout
tip (str) – The tooltip to apply to the labels and edit
- mylayout¶
Place this layout into the parent GUI, not the ComboBox
- reset()¶
Reset the labels and ComboBox to their default values
- setEnabled(state)¶
Set all child widgets to enabled state of state
- Parameters
state (bool) – True if widgets should be enabled, False if not
- setVisible(state)¶
Set all child widgets to visible state of state
- Parameters
state (bool) – True if widgets should be visible, False if not
- setToolTip(tip)¶
Set the tooltip for this widget
- Parameters
tip (str) – The tooltip to apply to the labels and spinbox
- class schrodinger.ui.qt.swidgets.SListWidget(parent=None, items=None, command=None, nocall=False, layout=None, emit='row', mode='single', drag=False, selection_command=None)¶
Bases:
PyQt6.QtWidgets.QListWidget
A QListWidget that can set its items and set up a callback at creation.
- __init__(parent=None, items=None, command=None, nocall=False, layout=None, emit='row', mode='single', drag=False, selection_command=None)¶
- Parameters
parent (QObject) – the parent object of this SListWidget
items (list) – list of str, the items are the entries in the ListWidget.
command (python callable) – The callback for when the current item is changed signal. The callback may be triggered before selected command signal.
emit (str) – ‘row’ if the signal emitted should be ‘currentRowChanged(‘int’)’ or else the signal will be ‘currentTextChanged[str]. The default is ‘row’
mode (str or QAbstractItemView.SelectionMode) – The selection mode - either ‘single’, ‘extended’, or a SelectionMode enum. The default is ‘single’.
drag (bool) – True if items can be dragged around in the listwidget. Note that if using actual QListWidgetItems, those items must have ItemIsDragEnabled and ItemIsSelectable flags turned on
nocall (bool) – False if the command parameter should be run when filling the widget during initialization, True if not. The default is False
layout (QLayout) – If supplied, the ListWidget created will be added to this layout
selection_command (python callable) – The callback for whenever the selection changes
- Note
Do not create a method named reset that calls self.clear() as that causes recursion errors. It’s probably best to avoid naming a method “reset” altogether as it appears to be some sort of private method of the class (that the public clear() method calls).
- allItems()¶
Return all the items in the list widget in order, including hidden ones
- Return type
list
- Returns
list of all QListWidgetItems in the list widget in order
- allItemsIter(role=ItemDataRole.UserRole)¶
Return a generator over text and data of the list widget, inspired by .items() method of dict.
- Parameters
role (int) – User role to pass do .data function
- Return type
generator(tuple(str, type))
- Returns
Generator over tupple of text and data of the list widget
- allText()¶
Return the list of all text values, including hidden items
- Return type
list
- Returns
List of strings
- removeItem(item)¶
Removes and returns the given item
- Parameters
item (QListWidgetItem or 0) – The item to be removed from the list widget or 0 if it is not found in the list widget
- removeItemByText(text)¶
Removes and returns the item with the given text
- Parameters
text (str) – the text of the item to be removed
- Return type
QListWidgetItem or None
- Returns
The removed item, or None if an item with the given text is not found.
- removeSelectedItems()¶
Removes selected items.
- setTextSelected(text, selected=True)¶
Selects the item with the given text. Will select hidden items too.
- Parameters
text (str) – the text of the item to be selected
selected (bool) – True if the item should be selected, False if it should be deselected.
- Return type
bool
- Returns
True if an item with the given text is found, False if not
- rowByText(text, match=MatchFlag.MatchExactly)¶
Returns the row that a given text is in. Also accounts for hidden items.
- Parameters
text (str) – The text to find
match (Qt.MatchFlag) – Type of match to search for - default is exact
- Return type
int or False
- Returns
Row that holds matched text (can be 0), if text is not matched, returns False
- selectedText()¶
Return the list of selected text values, including those of hidden items
- Return type
list
- Returns
List of strings, each member is the text of a selected item
- class schrodinger.ui.qt.swidgets.SFilteredListWidget(label=None, filterlabel='Filter:', filter='within', filterside='bottom', case=False, layout=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SListWidget
An SListWidget with an additional line edit that can be used to filter the items within the ListWidget
The SFilteredListWidget instance has a .mylayout property that all the widgets are placed into. This .mylayout should be added to another layout in order to place the widgets into the GUI - if the widget is not placed into the GUI directly via the layout= keyword.
Items are set to hidden when they don’t match the filter. Selected items that are set to hidden are unselected. Since items are hidden instead of deleted, currentRow() and rowByText() return the true index of the item, not the index among visible items.
- __init__(label=None, filterlabel='Filter:', filter='within', filterside='bottom', case=False, layout=None, **kwargs)¶
See the SListWidget documentation for additional keyword parameters.
- Parameters
label (str) – the text that will appear directly above the list widget
filterlabel (str) – the label above the filter line edit.
filter (str) – One of ‘within’, ‘start’, ‘end’. If within (default), the filter will find any item that has the filter text anywhere within its text. ‘start’ will only check if the item text starts with the filter ext, ‘end’ will only check if the item text ends with.
filterside (str) – One of ‘top’ or ‘bottom’ (default) - the location of the filter edit relative to the list widget
case (bool) – True if filter is case sensitive, False if not
- filterList(filtervalue)¶
Filter the items in the list widget according to the contents of the LineEdit and our filter rules
- Parameters
filtervalue (str) – The current value to filter the ListWidget by
- clear()¶
Removes all items from the ListWidget
- withinFilter(text, filtertext)¶
Checks whether filtertext is contained within text - case insensitive
- Parameters
text (str) – the text to check
filtertext (str) – will check for the existance of this text within text.
- Return type
bool
- Returns
True if filtertext is found within text, False if not
- startFilter(text, filtertext)¶
Checks whether text starts with filtertext
- Parameters
text (str) – the text to check
filtertext (str) – will check if text starts with filtertext.
- Return type
bool
- Returns
True if text starts with filtertext, False if not
- endFilter(text, filtertext)¶
Checks whether text ends with filtertext
- Parameters
text (str) – the text to check
filtertext (str) – will check if text ends with filtertext.
- Return type
bool
- Returns
True if text ends with filtertext, False if not
- class schrodinger.ui.qt.swidgets.SFrame(parent=None, layout=None, layout_type='vertical', indent=False)¶
Bases:
PyQt6.QtWidgets.QFrame
A Frame that can be placed in a layout and is given a layout when created
- __init__(parent=None, layout=None, layout_type='vertical', indent=False)¶
Create an SFrame instance. The frame has a mylayout property that is the internal layout.
- Parameters
parent (QObject) – the parent object of this SFrame
layout_type (string) – Module constants VERTICAL, HORIZONTAL, or GRID, for the type of internal layout
layout (QBoxLayout) – The layout to place this SFrame into
indent (bool or int) – False for a 0 left margin, True for a STANDARD_INDENT left margin, or an int for the value of the left margin - False by default.
- addWidget(widget)¶
Add widget to the frame layout.
- Parameters
widget (QWidget) – Widget to place on the layout
- addStretch()¶
Add stretch to the frame layout.
- class schrodinger.ui.qt.swidgets.SHLine(layout=None)¶
Bases:
PyQt6.QtWidgets.QFrame
A simple horizontal line
- __init__(layout=None)¶
Create a SHLine object
- Parameters
layout (QLayout) – If supplied, the line created will be added to this layout
- class schrodinger.ui.qt.swidgets.STwoButtonBox(layout=None, accept_text='Accept', accept_command=None, close_text='Close', close_command=None)¶
Bases:
PyQt6.QtWidgets.QWidget
A bottom button box that consists of a horizontal line over two buttons, an accept button on the left and a close button on the right.
- __init__(layout=None, accept_text='Accept', accept_command=None, close_text='Close', close_command=None)¶
Create a SHLine object
- Parameters
layout (QLayout) – If supplied, the line created will be added to this layout
accept_text (str) – The label on the accept button (“Accept” by default)
accept_command (callable) – The command the accept button should call. If this is not given or is None, the Accept button will not be created.
close_text (str) – The label on the close button (“Close” by default)
close_command (callable) – The command the close button should call. If this is not given or is None, the Close button will not be created.
- class schrodinger.ui.qt.swidgets.SEmittingScrollBar¶
Bases:
PyQt6.QtWidgets.QScrollBar
- showEvent(self, a0: Optional[QShowEvent])¶
- hideEvent(self, a0: Optional[QHideEvent])¶
- schrodinger.ui.qt.swidgets.draw_picture_into_rect(painter, pic, rect, max_scale=None, padding_factor=None)¶
Draw a QPicture into a given rectangle.
- Parameters
painter (QtGui.QPainter object) – QPainter object that will do the drawing into the cell.
pic (QPicture) – the picture to be drawn into the rectangle
rect (QRect) – the rectangle that defines the drawing region
max_scale (float or None) – The maximum amount to scale the picture while attempting to make it fit into rect. This value is multipled by the scale factor required to fit a 150(wide) x 100 (high) picture to fit that picture into rect. The resulting product (max_scale * reference picture scale) is the true maximum scale factor allowed.
- Padding_factor
If set, add padding on all 4 sides of QPicture, on the dimensions of the rectangle, to avoid it from “touching” the outer edges of the paint area. For 2D structure images, value of 0.04 is recommended.
- Returns
Rectangle that the QPicture was actually painted into. It’s a rectangle within
rect
- after removing padding on each side.- Return type
QRectF
- class schrodinger.ui.qt.swidgets.SToolButton(*args, text='', layout=None, tip=None, command=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QToolButton
Schrodinger-style QToolButton
- __init__(*args, text='', layout=None, tip=None, command=None, **kwargs)¶
Create an SToolButton instance
- Parameters
text (str) – The text of the button
layout (QtWidgets.QBoxLayout) – The layout for this button
tip (str) – The tooltip for this button
command (callable) – The command to connect the clicked signal to
- class schrodinger.ui.qt.swidgets.EditButton(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SToolButton
Edit button with custom Schrodinger icon.
- __init__(*args, **kwargs)¶
Create an SToolButton instance
- Parameters
text (str) – The text of the button
layout (QtWidgets.QBoxLayout) – The layout for this button
tip (str) – The tooltip for this button
command (callable) – The command to connect the clicked signal to
- class schrodinger.ui.qt.swidgets.HelpButton(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SToolButton
Help tool button that will show an ellipsis button on top when hovered. Clicking that or right clicking this button will launch a tutorial submenu.
- Variables
tutorialRequested – Signal for requesting launching a tutorial, emitted when a tutorial is clicked. This emits the tutorial topic string required to launch the help dialog.
- tutorialRequested¶
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)¶
Set up the tool button and the ellipsis button on top.
- setHelpTopic(help_topic: str)¶
Set the tutorial mapping for the menu using the given help topic. This map is used to populate the menu actions along with the tutorial ID.
- Parameters
help_topic – panel specific help topic
- emitTutorialSignal(action)¶
Emit the tutorial requested signal with the relevant tutorial type.
- enterEvent(self, a0: Optional[QEnterEvent])¶
- leaveEvent(self, a0: Optional[QEvent])¶
- classmethod getTutorialsJsonMap() Optional[Dict[str, Dict[str, str]]] ¶
Return the tutorials mapping for help topics from docs.
- Returns
Dictionary mapping of help topics to tutorial help topics and descriptions.
- class schrodinger.ui.qt.swidgets.EllipsisPopUpButton(parent)¶
Bases:
schrodinger.ui.qt.swidgets.SToolButton
- Variables
BUTTON_OFFSET (int) – Vertical overlap between the ellipsis button and the tool button
- BUTTON_OFFSET = 5¶
- __init__(parent)¶
- Parameters
parent (HelpButton) – Toolbutton to show ellipsis button over
- show()¶
Show the ellipsis button if neither it nor the popup widget are visible
- leaveEvent(event)¶
Hide the ellipsis button on mouse leave if the mouse isn’t over the tool button
- class schrodinger.ui.qt.swidgets.InfoButton(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SToolButton
Info button, with custom Schrodinger icon. Typically the only purpose of such icon is to display tooltip text when clicked or hovered.
- INFO_ICON = ':/schrodinger/ui/qt/icons_dir/info.png'¶
- INFO_H_ICON = ':/schrodinger/ui/qt/icons_dir/info_h.png'¶
- INFO_BUTTON_STYLESHEET = '\n QToolButton {\n border: none;\n padding: 0px 0px 0px 0px;\n image: url(:/schrodinger/ui/qt/icons_dir/info.png);\n }\n QToolButton:hover {\n image: url(:/schrodinger/ui/qt/icons_dir/info_h.png);\n }'¶
- __init__(*args, **kwargs)¶
Create an SToolButton instance
- Parameters
text (str) – The text of the button
layout (QtWidgets.QBoxLayout) – The layout for this button
tip (str) – The tooltip for this button
command (callable) – The command to connect the clicked signal to
- class schrodinger.ui.qt.swidgets.ResetButton(*args, layout=None, tip='Reset All', command=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QToolButton
Reset button, with custom Schrodinger icon.
- __init__(*args, layout=None, tip='Reset All', command=None, **kwargs)¶
- Parameters
layout (QLayout) – the layout that the widget created will be added to
tip (str) – the tooltip
command (callable) – Slot for the button click signal.
- class schrodinger.ui.qt.swidgets.SaveButton(*args, layout=None, tip=None, command=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QToolButton
Apply button with custom Schrodinger icon.
- __init__(*args, layout=None, tip=None, command=None, **kwargs)¶
- Parameters
layout (QLayout) – If supplied, the STableWidget created will be added to the layout.
tip (str) – the tooltip
command (callable) – Slot for the button click signal.
- class schrodinger.ui.qt.swidgets.CloseButton(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SToolButton
Close button with custom Schrodinger icon.
- __init__(*args, **kwargs)¶
Create an SToolButton instance
- Parameters
text (str) – The text of the button
layout (QtWidgets.QBoxLayout) – The layout for this button
tip (str) – The tooltip for this button
command (callable) – The command to connect the clicked signal to
- class schrodinger.ui.qt.swidgets.SmallCloseButton(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QPushButton
Small close button with “X” text.
- __init__(*args, **kwargs)¶
- class schrodinger.ui.qt.swidgets.TrashButton(*args, layout=None, tip=None, command=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QToolButton
Trash button with custom Schrodinger icon.
- __init__(*args, layout=None, tip=None, command=None, **kwargs)¶
- Parameters
layout (QLayout) – ‘the layout that the widget created will be added to’
tip (str) – the tooltip
command (callable) – Slot for the button click signal.
- class schrodinger.ui.qt.swidgets.LigandDetectionLink(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QLabel
A clickable label with text “Ligand Detection…” which opens the ligand detection Maestro preferences when clicked.
- __init__(*args, **kwargs)¶
- class schrodinger.ui.qt.swidgets.SDialog(master, user_accept_function=None, standard_buttons=None, nonstandard_buttons=None, help_topic='', title=None)¶
Bases:
PyQt6.QtWidgets.QDialog
A Base Dialog class for easier Dialog creation
- __init__(master, user_accept_function=None, standard_buttons=None, nonstandard_buttons=None, help_topic='', title=None)¶
Creat an SDialog object
- Parameters
master (QWidget) – The parent of this dialog
user_accept_function (callable) – A function to call from a custom accept method implemented in a subclass
standard_buttons (list) – List of standard buttons to add - each item must be a QDialogButtonBox.StandardButton constant (i.e. QDialogButtonBox.Ok). The default if no standard buttons or non-standard buttons are provided is Ok and Cancel.
nonstandard_buttons (list of (QPushButton, QDialogButtonBox.ButtonRole) tuples) – Each item of the list is a tuple containing an existing button and a ButtonRole such as AcceptRole. The default if no standard buttons or non-standard buttons are provided is Ok and Cancel buttons.
help_topic (str) – The help topic for this panel. If the help topic is provided a help button will automatically be added to the panel.
title (str) – The dialog window title
- layOut()¶
Lay out the custom widgets in this dialog.
- giveHelp()¶
Display the help topic for this dialog
- warning(msg)¶
Display a warning dialog with a message
- Parameters
msg (str) – The message to display in the warning dialog
- info(msg)¶
Display an information dialog with a message
- Parameters
msg (str) – The message to display in the information dialog
- error(msg)¶
Display an error dialog with a message
- Parameters
msg (str) – The message to display in the error dialog
- reset()¶
Reset the panel when the Reset button is pressed. Must be re-implemented in a subclass
- question(msg, button1='OK', button2='Cancel')¶
Display a question dialog with a message Returns True if first button (default OK) is pressed, False otherwise.
- Parameters
msg (str) – The message to display in the question dialog
button1 (str) – The text to display on first button
button2 (str) – The text to display on second button
- class schrodinger.ui.qt.swidgets.NewNameDialog(parent, default_name, existing_names, overwrite_existing_names=True, validator=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SDialog
Dialog for getting a new name from the user
- __init__(parent, default_name, existing_names, overwrite_existing_names=True, validator=None, **kwargs)¶
Create a NewNameDialog instance
- Parameters
parent (QtWidgets.QWidget) – the parent widget
default_name (str) – The default name
existing_names (iterable) – The existing names
validator (QtGui.QValidator) – The validator to make sure the given name is acceptable. If
None
, then no validator is used.overwrite_existing_names (bool) – Whether you want to allow the user to overwrite a name that already exists
- layOut()¶
Layout the widgets
- getName()¶
Return the name.
- Return type
str
- Returns
the name
- accept()¶
Check that the name is valid before accepting.
- Return type
None
- Returns
None is always returned, if None is returned before the super then the result is not accepted
- class schrodinger.ui.qt.swidgets.SMARTSEdit(master, tag=None, empty_ok=True, label='SMARTS:', indicator=True, indicator_state=0, indicator_tips=True, canvas_api=False, rdkit_api=True, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLabeledEdit
A line edit for entering SMARTS strings with an icon that indicates the SMARTS’ validity
- smarts_data_changed¶
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.
- invalid_smarts_changed¶
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__(master, tag=None, empty_ok=True, label='SMARTS:', indicator=True, indicator_state=0, indicator_tips=True, canvas_api=False, rdkit_api=True, **kwargs)¶
Create a SMARTSEntry object
- Parameters
master (QWidget) – Something with a warning method for displaying warning dialogs
tag (str) – A string that defines the edit for use in warning messages. ex. “No valid SMARTS pattern for ‘tag’”. If not supplied, a generic message will be used.
empty_ok (bool) – Whether an empty edit is considered VALID or INTERMEDIATE
label (str) – The label preceeding the QLineEdit
indicator (bool) – True if a valid/invalid indicator should be appended
indicator_state (bool) – The default state of the indicator (INDICATOR_VALID, INDICATOR_INVALID or INDICATOR_INTERMEDIATE)
indicator_tips (dict) – The tooltips for the different states of the indicator - see the SValidIndicator class for more information. If not provided, they can be given directly in the setIndicator call. If not given in either place, the indicator will have default tooltips. Pass in None to have no tooltips at all.
canvas_api (bool) – toggle whether to verify with analyze.validate_smarts or analyze.validate_smarts_canvas (defaults to validate_smarts_canvas)
rdkit_api (bool) – Whether to verify with adapter.validate_smarts. It cannot be used with canvas_api.
See the parent
SLabeledEdit
class for additional keyword arguments
- setEmptyOK(is_ok)¶
Set whether an empty edit is considered VALID or INTERMEDIATE
- Parameters
is_ok (bool) – Whether an empty edit is VALID
- isInvalid()¶
Is the line edit currently colored as invalid?
- Return type
bool
- Returns
Whether the line edit has the invalid color
- isValid()¶
Is the line edit currently colored as valid?
- Return type
bool
- Returns
Whether the line edit has the valid color
- startedEditingSMARTS()¶
React to the SMARTS pattern changing but not yet finished
- doneEditingSMARTS(force=False)¶
The SMARTS pattern is complete, so validate it if necessary
- Parameters
force (bool) – Force the SMARTS pattern to be validated even if the existing state is invalid.
- getSMARTSPatterns(raise_if_empty=False)¶
Get a list of the current SMARTS patterns specified by the user
- Parameters
raise_if_empty (bool) – Whether to raise an error if the checkbox is checked but the line edit is empty
- Return type
list
- Returns
An empty list if the checkbox is not checked, or the contents of the edit converted via whitespace to a list of strings if the checkbox is checked.
- Raises
ValueError – if raise_if_empty is True, the checkbox is checked, and the edit is empty
- validateSMARTS(pattern)¶
Validate smarts pattern
- Parameters
pattern (str) – The smarts pattern to validate
- Return type
(bool, str)
- Returns
The bool indicates whether the SMARTS pattern is valid, the string gives the error message if bool is False Note: the return value of this function always evaluates to True since it is a non-empty tuple.
- findSMARTSError(verbose=True)¶
Find any error in the SMARTS patterns
- Parameters
verbose (bool) – Whether to post a warning dialog with the error found
- Return type
str
- Returns
An empty string if no error is found, or an error message describing the error that was found
- setText(text)¶
Overrides the parent method to also evaluate the new SMARTS string
- clear()¶
Overrides the parent method to also evaluate the new SMARTS string
- class schrodinger.ui.qt.swidgets.ColorWidget(parent_layout, text, default_rgb_color=(0, 0, 255), check_box_state=None, pixmap_size=16, stretch=True, use_maestro_colors=False, command=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SFrame
A QtWidgets.QFrame to manage a color widget.
- color_changed¶
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__(parent_layout, text, default_rgb_color=(0, 0, 255), check_box_state=None, pixmap_size=16, stretch=True, use_maestro_colors=False, command=None, **kwargs)¶
Create an instance.
- Parameters
parent_layout (QtWidgets.QVBoxLayout) – the layout this widget belongs in
text (str) – the text for the widget
default_rgb_color (tuple) – a triple of integers in [0, 255] that give RGB colors
check_box_state (None or bool) – None indicates that the widget should not be behind a check box, the bool indicates that (1) the widget should be behind a check box and (2) that by default should be checked (True) or unchecked (False)
pixmap_size (int) – the size of the pixmap used for the coloring button
stretch (bool) – whether to add a stretch space after the color button
use_maestro_colors (bool) – whether to map selected rgb colors to nearby rgb colors that are also supported by color name, for example “spring green”, in Maestro (see names in mmshare/mmlibs/mmcolor/colors.res)
command (callable) – Slot for the color_changed signal, which is emitted when the button color changes. The command is not called when the button is created. command is called with a triple of integers in [0, 255] that give the new RGB colors.
- mapToMaestroColor(rgb_color)¶
Map the given rgb color to a nearby rgb color that is also supported by color name, for example “spring green”, in Maestro.
- Parameters
rgb_color (tuple) – a triple of integers in [0, 255] that give RGB colors
- Type
tuple
- Returns
a triple of integers in [0, 255] that give RGB colors for the color that is supported by name in Maestro
- setButtonColor(rgb_color)¶
Set the button color.
- Parameters
rgb_color (tuple) – a triple of integers in [0, 255] that give RGB colors
- enableButtonViaCheckBox()¶
Enable/disable the color button via the checkbox state.
- openColorSelector()¶
Open the color selector dialog.
- reset()¶
Reset it.
- class schrodinger.ui.qt.swidgets.STableView(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QTableView
Just like a QTableView except:
LineEditDelegate is the default delegate. It draws “pencil” icons in cells that are editable.
Cells whose delegates have MOUSE_CLICK_STARTS_EDIT set will enter the edit mode as soon as the user clicks (press & release) in the cell.
Cells whose delegates have MOUSE_PRESS_STARTS_EDIT set will enter the edit mode as soon as the user presses the mouse button.
- __init__(*args, **kwargs)¶
Create a STableView instance.
- class schrodinger.ui.qt.swidgets.STableWidgetItem(editable=True, selectable=True, enabled=True, user_checkable=True, text='', vertical_align=AlignmentFlag.AlignVCenter, horizontal_align=AlignmentFlag.AlignHCenter)¶
Bases:
PyQt6.QtWidgets.QTableWidgetItem
Table widget item with proper sorting of numbers
- SELECT_ITEM = 1¶
- ENABLE_ITEM = 32¶
- EDITABLE_ITEM = 2¶
- CHECKABLE_ITEM = 16¶
- TOP = 32¶
- VCENTER = 128¶
- BOTTOM = 256¶
- VERTICAL_ALIGNS = {AlignmentFlag.AlignTop, AlignmentFlag.AlignVCenter, AlignmentFlag.AlignBaseline}¶
- LEFT = 1¶
- HCENTER = 4¶
- RIGHT = 2¶
- JUSTIFY = 8¶
- HORIZONTAL_ALIGNS = {AlignmentFlag.AlignLeft, AlignmentFlag.AlignRight, AlignmentFlag.AlignHCenter, AlignmentFlag.AlignJustify}¶
- __init__(editable=True, selectable=True, enabled=True, user_checkable=True, text='', vertical_align=AlignmentFlag.AlignVCenter, horizontal_align=AlignmentFlag.AlignHCenter)¶
QTableWidgetItem item which holds the value (numerical if appropriate) of text hence sorting the items properly if they are numbers. Also can easily set the item’s state and text allignment.
- Parameters
editable (bool) – Whether the items will be configured to be editable; only occurs if the items have the option to be editable.
selectable (bool) – If true then item will be selectable, else not.
enabled (bool) – If true then item will be enabled, else not.
user_checkable (bool) – If true then item will be checkable to user, else not.
text (str) – The text for the table item
vertical_align (str) – Define vertical align style to top, center, or bottom. Bottom uses AlignBaseline instead of AlignBottom as AlignBottom causes text to disappear.
horizontal_align (str) – Define horizontal align style to left, center, right, or justify.
- Raises
AssertionError if value of horizontal_align is not left, center, right, or justify.
- Raises
AssertionError if value of vertical_align is not top, center, or bottom.
- getValue()¶
Get the value of the current text if it is numerical text.
- Return type
float or text
- Returns
float if text is numerical text, else will return text itself.
- copy()¶
Return copy of current item with same flags and text as the current one.
- Return type
STableWidgetItem (or current class)
- Returns
copy of current item
- class schrodinger.ui.qt.swidgets.STableWidget(*arg, columns=None, column_names=None, table_data=None, row_data_names=None, sort_column=None, sort_style='ascending', select_row=False, resize_header=False, layout=None, row_data_col=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QTableWidget
A better table widget
- SORT_ASC = 'ascending'¶
- __init__(*arg, columns=None, column_names=None, table_data=None, row_data_names=None, sort_column=None, sort_style='ascending', select_row=False, resize_header=False, layout=None, row_data_col=None, **kwargs)¶
Create a STableWidget instance.
- Parameters
table_data (numpy.ndarray or list) – 2-dimension numpy array containing data for the table or list of list where inner lists is list of values for each row.
columns (dict) – Ordered dictionary with key as column names and value as the STableWidgetItem. This item will be used a base item for all the items for the column. None can be used for the value for columns that contain only widgets.
column_names (list) – list of column names and base item for each column will be set as STableWidgetItem. If both columns and column_name is provided then column_names are ignored.
row_data_names (list) – list containing names of each row data. row_data is data stored in under user role in table item widget in the row_data_col column.
sort_column (str or int or None) – name or index of column to sort by. If none then sort is not enabled.
sort_style (str) – select sorting type between ascending or descending
select_row (bool) – enable selection of rows rather than individual items
resize_header (bool or str) – If True, resize last column header to fill the available space. The size cannot be changed by the user or programmatically. If a string, must be the name of the column that will stretch to fill all available space.
layout (QLayout) – If supplied, the STableWidget created will be added to the layout.
row_data_col (str) – The header name for the column that will store any row data
- resizeHeaders()¶
If necessary, sets the width of the table headers and sets the appropriate column to a stretch mode
- cellWidget(*args)¶
Get the widget for the cell
Overwrites parent method to account for CenteringWidgets that hold the widget of interest as a child widget
See parent method for additional details
- updateColumnNames()¶
Updates the column count and header labels according to the contents of
self.columns
.
- renameColumn(current_column, new_column)¶
Rename a single column.
- Parameters
current_column (str) – the existing column header to be updated
new_column (str) – the new column header
- setColumnCount(columns)¶
Sets the number of columns in the table to columns. If this is less than columnCount(), the data in the unwanted columns is discarded. If it is more than columnCount() then default base item is created for the column
- Parameters
columns (int) – Number of columns for the table
- setHorizontalHeaderLabels(columns)¶
Sets the horizontal header labels using labels.
- Parameters
columns (list) – list of column labels for the table. Only the name will be changed for the column and the base item will remain the same.
- setSortingEnabled(enable, sorting_column=0, sort_style='ascending')¶
Update parent class to enable sorting by set column
- Parameters
enable (bool) – If enable is true it enables sorting for the table and immediately triggers a call to sortByColumn() with the set sorting column and style
sort_column (str or int or None) – name or index of column to sort by. If none then sort is not enabled.
sort_type (str) – select sorting type between ascending or descending
- getRows(selected_only=False)¶
A generator for all table rows.
- Parameters
selected_only (bool) – If true it will only return selected rows
- Return type
list
- Returns
Iterates over each row to return list of QTableWidgetItem
- getSelectedRowIndexes()¶
Get row indexes numbers of selected rows.
- Return type
list
- Returns
list containing indexes of selected rows
- addRow(data, return_sorted=True, editable=True)¶
Add a row to the table.
- Parameters
data (list or dict) – list data values for the column ordered as columns are. followed by row data values in order of as set in row_data_names. If a dict is supplied, keys are column names or row data names and values are the values for that column/row data. Any keys missing from the dict will cause nothing to be added to that column. Widgets can be added to any column simply by supplying a widget as the list item/dict value for that column. For an empty cell, pass an empty string as the value of the list item. Note that a
None
value will skip the setCell() function.return_sorted (bool) – return sorted table
editable (bool) – Whether the added items will be configured to be editable; only occurs if the items have the option to be editable.
- addColumn(column_name, base_item=None, index=None)¶
Add a column to the table
- Parameters
column_name (str) – The header of the new column to add
base_item (STableWidgetItem) – The base item for all items in this new column. If
None
, then the base item will be an emptySTableWidgetItem
.index (int) – The 0-indexed location at which you want to add the column. If
None
, the new column will be appended to the end.
- Raises
ValueError – If a duplicate
column_name
is provided.
- insertColumn(column)¶
The
insertColumn
method ofQTableWidget
is unsafe to use inSTableWidget
. Please use theaddColumn
method instead.
- setCell(value, row_idx, col_idx, editable=True)¶
Sets a cell in the table to the given value
- Parameters
value (str or QtWidgets.QWidget) – the value to set the cell to
row_idx (int) – the row index of the cell you want to set
col_idx (int) – the column index of the cell you want to set
editable (bool) – Whether the item will be configured to be editable; only occurs if the item has the option to be editable.
- getColumnIndex(column_name)¶
Get index of the given column name. Row data columns are not indexable.
- Parameters
column_name (str) – Name of the column of get index of
- Return type
int
- Returns
index of the given column
- sortRows()¶
Sort the rows by given sortable column
- addRows(table_data, editable=True)¶
Add a rows to the table
- Parameters
table_data (numpy.ndarray or list) – 2-dimension numpy array containing data for the table or list of list where inner lists is list of values for each row.
editable (bool) – Whether the added items will be configured to be editable; only occurs if the items have the option to be editable.
- deleteAllRows()¶
Delete all rows in the table.
- deleteSelectedRows()¶
Delete the selected rows from the table.
- deleteColumn(column_name)¶
Deletes the column with the given name/header
- Parameters
column_name (str) – the header of the column you want to delete
- Raises
ValueError – if the name of the given column does not exist in this table
- reset()¶
Reset the table by deleting all the rows and reverting the columns to their initial state
- selectOnlyRows(rows)¶
Select only specified rows
- Parameters
rows (list) – list of row numbers
- class schrodinger.ui.qt.swidgets.ProjectTableButton(parent=None)¶
Bases:
PyQt6.QtWidgets.QToolButton
A button with a project table logo. When clicked, it will open the project table panel.
- __init__(parent=None)¶
- launchProjectTable()¶
- class schrodinger.ui.qt.swidgets.TextSearchBar(parent=None, placeholder_text='text in page')¶
Bases:
PyQt6.QtWidgets.QWidget
A compound widget for performing a simple text search. Consists of a text field with placeholder, previous and next match buttons, and a cancel button that will hide the search bar.
- nextMatchRequested¶
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.
- prevMatchRequested¶
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__(parent=None, placeholder_text='text in page')¶
- Parameters
placeholder_text (str) – placeholder text to show in the text field
- onPrevBtnClicked()¶
- onNextBtnClicked()¶
- searchKeyPressed(e)¶
Checks a QEvent from keyPressEvent for the search bar invocation key combo (i.e. Ctrl-F or Cmd-F). If the key combo is detected, show the search bar, put focus on the text field, and return True. Otherwise return False.
Typical usage in MyPanel:
def keyPressEvent(self, e): if self.search_bar.searchKeyPressed(e): return super(MyPanel, self).keyPressEvent(e)
- Parameters
e (QEvent) – the event to be checked
- schrodinger.ui.qt.swidgets.get_picture_as_text(pic, width=200, height=150)¶
Saves a QPicture to an image, returns the 64 base string for the image, so that it can be displayed as a tooltip.
- class schrodinger.ui.qt.swidgets.SpinBoxDoubleSlider(parent=None, range_min=- 1.0, range_max=1.0, min_value=- 1.0, max_value=1.0, stepsize=0.2, decimals=2, command=None, nocall=True, layout=None)¶
Bases:
PyQt6.QtWidgets.QWidget
This widget is made up of a double slider widget with a double spinbox on each side. It allows selection of a sub-range from a given range of values.
Originally copied from mmshare/python/scripts/watermap_result_gui_dir/cutoff_slider.py and expanded with additional functionality.
- cutoffChanged¶
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__(parent=None, range_min=- 1.0, range_max=1.0, min_value=- 1.0, max_value=1.0, stepsize=0.2, decimals=2, command=None, nocall=True, layout=None)¶
Create an SpinBoxDoubleSlider object
- Parameters
parent (QObject) – the parent object of this SpinBoxDoubleSlider
minimum – The minimum value this SpinBoxDoubleSlider can take on. The reset method will also reset the range of the slider using this value.
maximum – The maximum value this SpinBoxDoubleSlider can take on. The reset method will also reset the range of the slider using this value.
value – The initial minimum (left slider) value of this SpinBoxDoubleSlider. This value will also be used as the default left slider value by the reset method.
value – The initial maximum (right slider) value of this SpinBoxDoubleSlider. This value will also be used as the default right slider value by the reset method.
stepsize (float) – The stepsize each spinbox arrow click changes the value by
decimals (int) – Number of decimal places to display in each spinbox
layout (QLayout) – If supplied, the SpinBoxDoubleSlider created will be added to this layout
command (python callable) – The callback for the cutoffChanged signal. This command will be called during initialization unless nocall is set to True.
nocall (bool) – True if the callback command should not be called during initialization, False if the command should be called.
- showEvent(event)¶
See parent class for documentation
- setStepSize(stepsize)¶
Set the stepsize values for both spinboxes
- Parameters
stepsize (float) – The new stepsize
- setRange(min_range, max_range)¶
Set the range for the slider and the spinboxes
- Parameters
min_range (float) – The minimum value
max_range (float) – The maximum value
- getRange()¶
- setValues(lpos, rpos)¶
- getValues()¶
- getTrueValues()¶
Get the actual min and max values rather than that represented by the spin box. The two may differ because the spinbox values are truncated at a certain number of decimal points
- Return type
(float, float)
- Returns
The values of the left and right sliders
- reset()¶
Reset the spinboxes and sliders to their original value. Only the values are reset, not other parameters (consistent with other swidgets such as spinboxes
- class schrodinger.ui.qt.swidgets.EditWithFocusOutEvent(*args, focus_out_command=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLabeledEdit
SLabeledEdit that calls ‘focus_out_command’ on returnPressed() and on ‘focusOutEvent’ with modified text.
- __init__(*args, focus_out_command=None, **kwargs)¶
Initialize EditWithFocusOutEvent.
- Parameters
focus_out_command (method) – Method to be called when focus out event occurs
- focusOutEvent(event)¶
Call self.focus_out_command when text modified, if present. This does NOT create race conditions with SLineEdit.eventFilter for always_valid=True. And the focus_out_command is only executed when the text is changed.
- Parameters
event (QEvent) – Focus out event
- class schrodinger.ui.qt.swidgets.SLabeledSlider(text, parent=None, minimum=1, maximum=100, stepsize=1, ticks=True, tick_interval=25, value=50, float_step=1, float_decimals=2, layout=None, command=None, nocall=True, stretch=True, after_label=None, value_label=True, orientation='horizontal', tip=None)¶
Bases:
PyQt6.QtWidgets.QSlider
A slider with text label to the left of it and a value label to the right of it that gives the current slider value. An additional label to the right of the value label (“after_label”) can be used for units, etc. The slider can be used to control and display integer or floating point data.
The widget has a mylayout property that points to the internal layout that contains all the widgets. This layout is added to the layout provided by the “layout” keyword, or can be manually added to a layout after creation.
- __init__(text, parent=None, minimum=1, maximum=100, stepsize=1, ticks=True, tick_interval=25, value=50, float_step=1, float_decimals=2, layout=None, command=None, nocall=True, stretch=True, after_label=None, value_label=True, orientation='horizontal', tip=None)¶
Create an SLabeledSlider object
- Parameters
text (str or None) – The text of the label - if None, no leading label is created
parent (QObject) – the parent object of this SLabeledSlider
minimum (int) – The minimum value of this SLabeledSlider
maximum (int) – The maximum value of this SLabeledSlider
stepsize (int) – The amount the value changes each time an arrow key is pressed
tick_interval (int) – The interval between tick marks
value (int) – The initial value of this SLabeledSlider. This value will also be used as the default value by the reset method.
float_step (float) – QSliders only deal with integer values but often need to control float values. Use float_step to provide the factor that the slider integer value gets multiplied by to get the float value. This floating point value is displayed in the value_label and returned by the floatValue method.
float_decimals (int) – The number of decimal places to show in the value_label if the value_label is displayed and float_step is provided.
layout (QLayout) – If supplied, the SLabeledSlider created will be added to this layout
command (python callable) – The callback for the valueChanged signal. This command will not be called during initialization unless nocall is set to False.
nocall (bool) – True (default) if the callback command should not be called during initialization, False if the command should be called.
stretch (bool) – Whether to put a stretch after the SLabeledSlider (or after the after_label). Default is True.
after_label (str) – Label text to put after the SLabeledSlider - default is None
value_label (bool) – If True, place a label directly after the slider that gives the current value of the slider. Units can be added to this value via the after_label keyword. The after_label will be placed immediately after the value_label.
orientation (str) – The orientation of the slider. Should be one of the module constants VERTICAL or HORIZONTAL.
tip (str) – The tooltip to apply to the labels and slider
- setToolTip(tip)¶
Add the tooltip to the slider and all labels
- Parameters
tip (str) – The tooltip to add
- setEnabled(state)¶
Set the slider’s and labels’ enabled states
- Parameters
state (bool) – Whether the slider and labels are enabled or not
- setMaximum(maximum)¶
Set the maximum value possible for the slider
- Parameters
maximum (int) – The maximum value for the slider
- reset()¶
Reset the value of the slider
- setupValueLabel()¶
Set up the value label. Can be called to setup a label in a custom layout as the widget’s value label
- updateValueLabel()¶
Set the value label text based on the current slider value
- floatValue()¶
Get the current float value. The float value differs from the slider value in that the slider value is an integer, while the float value is a float calculated by multiplying float_step by the integer value.
- Return type
float
- Returns
The current widget float value
- setFloatValue(float_value)¶
Set the current float value of the slider. The value gets rounded to the nearest acceptable slider value.
- Parameters
float_value (float) – The value to set
- toInt(float_value)¶
Convert a float value to the equivalent int value for the slider
- Parameters
float_value (float) – The value to convert
- Return type
int
- Returns
The integer equivalent of float_value
- setFloatMaximum(float_maximum)¶
Set the maximum float value of the slider. The maximum gets rounded to the nearest acceptable slider value.
- Parameters
float_maximum (float) – The new maximum
- setFloatMinimum(float_minimum)¶
Set the minimum float value of the slider. The minimum gets rounded to the nearest acceptable slider float value.
- Parameters
float_minimum (float) – The new minimum
- setVisible(state)¶
Set all child widgets to the visible state
- Parameters
state (bool) – True if widgets should be visible, False if not
- class schrodinger.ui.qt.swidgets.STabWidget(parent=None, tabs=None, layout=None, command=None, nocall=True)¶
Bases:
PyQt6.QtWidgets.QTabWidget
A QTabWidget with additional convenience methods
- __init__(parent=None, tabs=None, layout=None, command=None, nocall=True)¶
Create an STabWidget instance
- Parameters
parent (QWidget) – The parent widget for this widget
tabs (dict) – Tabs to create and add to the STabWidget. Keys are tab labels, values are widgets for that tab
layout (QLayout) – If supplied, the STabWidget created will be added to this layout
command (python callable) – The callback for the currentChanged signal. This command will not be called during initialization unless nocall is set to False.
nocall (bool) – True (default) if the callback command should not be called during initialization, False if the command should be called.
- reset()¶
Reset the STabWidget by calling reset on each individual tab. Tabs without a reset() method will be skipped
- tabs()¶
A generator for all tab widgets
- Ytype
QWidget
- Yield
Iterates over each tab widget in index order
- getTabByLabel(label)¶
Return the tab widget with the given label
- Parameters
label (str) – The label of the desired tab
- Return type
QWidget
- Returns
The tab widget with the given label
- Raises
ValueError – If no tab with this label is found
- setCurrentLabel(label)¶
Set the tab with the given label to be the current tab
- Parameters
label (str) – The label of the tab to make current
- currentLabel()¶
Get the label of the current tab
- Return type
str
- Returns
The label of the current tab
- setTabVisibleByLabel(label, visible)¶
Set the tab visibility by label.
- Parameters
label (str) – the label of the tab for which to set the visibility
visible (bool) – True if the tab should be visible, False otherwise
- isTabVisibleByLabel(label)¶
Return True if the tab for the given label is visible.
- Parameters
label (str) – the label of the tab to check
- Return type
bool
- Returns
True if the tab is visible
- visibleTabs()¶
A generator for all visible tab widgets
- Ytype
QWidget
- Yield
Iterates over each visible tab widget in index order
- class schrodinger.ui.qt.swidgets.PlaceholderComboMixin(parent=None, placeholder='Please select an option...', **kwargs)¶
Bases:
object
Deprecated in favor of combo_boxes.ItalicsPlaceholderComboBox, which uses the new Qt API for setting placeholder text, and is a widget instead of a mixin.
- __init__(parent=None, placeholder='Please select an option...', **kwargs)¶
- paintEvent(event)¶
This reimplements QComboBox.paintEvent based on the C++ implementation.
It uses italic font to paint _placeholder_text when the index is -1
- class schrodinger.ui.qt.swidgets.StyleMixin¶
Bases:
object
In order to style custom QWidget subclasses using stylesheet, this custom paintEvent method must be implemented.
- paintEvent(e)¶
See
QtWidgets.QWidget
documentation for more information.
- class schrodinger.ui.qt.swidgets.SRetainableMenu(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QMenu
A menu that doesn’t get closed after selecting an item
- __init__(*args, **kwargs)¶
- eventFilter(self, a0: Optional[QObject], a1: Optional[QEvent]) bool ¶
- class schrodinger.ui.qt.swidgets.SSplitter(orientation=Orientation.Horizontal, collapsible=False, expanding=True, layout=None, widgets=None, **kwargs)¶
Bases:
PyQt6.QtWidgets.QSplitter
- __init__(orientation=Orientation.Horizontal, collapsible=False, expanding=True, layout=None, widgets=None, **kwargs)¶
A customized QSplitter widget
- Parameters
orientation (enum) – Either Qt.Horiztonal or Qt.Vertical
collapsible (bool) – Whether the panes can be collapsed or not
expanding (bool) – Whether the splitter can expand in the direction opposite of the splitter orientation
layout (QtWidgets.QBoxLayout) – The layout to place this into
widgets (list) – A list of widgets to add to the splitter
- class schrodinger.ui.qt.swidgets.CenteringWidget(widget, layout_margins=None)¶
Bases:
PyQt6.QtWidgets.QWidget
A widget used to center other widgets when placed in a table cell
- __init__(widget, layout_margins=None)¶
Create a CenteringWidget object
- Parameters
widget (QtWidgets.QWidget) – The widget to center
- class schrodinger.ui.qt.swidgets.SelectorWithPopUp(label, default_selection, layout=None, stretch=True)¶
Bases:
schrodinger.ui.qt.swidgets.SFrame
A frame that contains a label, read-only line edit, and a tool button that shows a pop up list. Requires a TOOL_BUTTON_CLASS to be defined in children.
- __init__(label, default_selection, layout=None, stretch=True)¶
Create a SelectorWithPopUp instance
- Parameters
label (str) – The label for the edit
default_selection (str) – The default selection for the edit and list
layout (QLayout) – The layout to place the frame in
- getSelection()¶
Get the current selection
- Return type
str
- Returns
The current selection
- clearFilters()¶
Clear the filters and make all options visible
- selectionChanged()¶
Callback for when a new item is selected in the pop up list
- schrodinger.ui.qt.swidgets.center_widget_in_table_cell(table, row, column, widget, layout_margins=None, item_type=<class 'schrodinger.ui.qt.swidgets.STableWidgetItem'>)¶
Centers the widget in the cell and adds a non-selectable widget item so the cell background can’t be selected
- Parameters
table (QTableWidget) – The table that contains the cell & widget
row (int) – The row of the cell
column (int) – The column of the cell
widget (QWidget) – The widget that will be placed into the cell and centered
layout_margins (tuple) – Tuple containing left, top, right, and bottom margins to use around the layout
item_type (class) – The class for the create table widget item
- class schrodinger.ui.qt.swidgets.DeleteButton(*args, command=None, horizontal_policy=Policy.Fixed, layout=None, tip=None)¶
Bases:
PyQt6.QtWidgets.QToolButton
A QToolButton that accepts the delete command callback for the clicked() signal as an argument
- __init__(*args, command=None, horizontal_policy=Policy.Fixed, layout=None, tip=None)¶
Accepts all arguments given for a QToolButton
- Parameters
command (function) – Delete function to call when the button emits a ‘clicked’ signal
horizontal_policy (QtWidgets.QSizePolicy.Policy) – If QSizePolicy.Fixed (default), the button horizontal size policy will be ‘fixed’. If None, it will be the QtWidgets.QToolButton default. Otherwise, the horizontal policy will be set to the value given by this parameter.
layout (QLayout) – Layout to place the button in
tip (str) – The tooltip for this delete button
- class schrodinger.ui.qt.swidgets.PersistentMenu(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QMenu
Menu that will persist when certain actions are triggered.
All actions that need to persist the menu should be added using
addPersistentAction
.- __init__(*args, **kwargs)¶
- eventFilter(self, a0: Optional[QObject], a1: Optional[QEvent]) bool ¶
- addPersistentAction(text: str, checkable: bool = False, checked: bool = False) PyQt6.QtGui.QAction ¶
Add a persistent action to the menu.
- removeAction(action: PyQt6.QtGui.QAction)¶
Remove the action from the persistent action set.
- class schrodinger.ui.qt.swidgets.ItemsManagerMixin¶
Bases:
object
A mixin that provides methods to save, delete, load and dump user created items to/from preferences. An item can be anything like ASL, SMARTS, Smiles, strings etc…
- PREF_KEY = None¶
- ITEM_TYPE_TEXT = 'item'¶
- getNameAndSave(value, default_name='')¶
Shows a
NewNameDialog
to provide a name to save the value to preferences.- Parameters
value (Any builtin jsonable type. Ex:
list
but notset
) – Value to be saved to preferencesdefault_name (
str
) – Default name to populate theNewNameDialog
- deleteSavedItem(name)¶
Remove the saved item with this name from the preferences
- Parameters
name (
str
) – Item name to remove
- getSavedItems()¶
Get all saved items from preferences
- Returns
Dict where keys are names and values are items
- Return type
dict
- dumpSavedItems(saved_items_dict)¶
Store all saved items to preferences
- Parameters
saved_items_dict (
dict
) – dict where keys are names and values are items
- class schrodinger.ui.qt.swidgets.StdMenuItem(name, value, parent)¶
Bases:
PyQt6.QtWidgets.QPushButton
Menu item for the standard items (non-deletable)
- Variables
itemClicked (
QtCore.pyqtSignal
) – A signal emitted when this standard item is clicked.
- itemClicked¶
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__(name, value, parent)¶
- Parameters
name (
str
) – Display text of the menu itemvalue (
str
) – Internal value of the menu itemparent (
QtWidgets.QWidget
) – Parent of the item
- class schrodinger.ui.qt.swidgets.SavedMenuItem(name, value, item_type_text='item')¶
Bases:
PyQt6.QtWidgets.QWidget
Menu item for the user saved items, which can be deleted.
- Variables
itemClicked (
QtCore.pyqtSignal
) – A signal emitted when this saved item is clicked. The value can be any builtin jsonable type.deleteClicked (
QtCore.pyqtSignal
) – A signal emitted when this saved item is deleted
- itemClicked¶
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.
- deleteClicked¶
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__(name, value, item_type_text='item')¶
- Parameters
name (
str
) – Display text of the menu itemvalue (
str
) – Internal value of the menu itemitem_type_text (
str
) – Display text for the item type
- class schrodinger.ui.qt.swidgets.SavedItemsManager(parent, item_clicked_func, get_value_func, std_items_file=None)¶
Bases:
PyQt6.QtWidgets.QToolButton
,schrodinger.ui.qt.swidgets.ItemsManagerMixin
A manager widget (basically a toolbutton), that manages standard and user saved items. Derive this class to manage a specific item like SMARTS, ASL, Smiles or normal strings.
On clicking, this toolbutton pops up a menu with the first item to save the item, followed by the list of already saved items and the last section with the list of standard items.
- PREF_KEY = None¶
- ITEM_TYPE_TEXT = 'item'¶
- __init__(parent, item_clicked_func, get_value_func, std_items_file=None)¶
- Parameters
parent (
QtWidgets.QWidget
) – The parent of this widgetitem_clicked_func (callable) – Function to call when a menu item it clicked in the popup menu. Should take any builtin jsonable type.
get_value_func (callable) – Function to call to get the item value to be saved. Should take no arg and returns any builtin jsonable value.
std_items_file (
str
) – File path containing the standard items in json format. Should be a dict at top level containing items with item name as key and item value as value
- readStdItems(std_items_file)¶
Read the standard items from the std_items_file. The standard items are specified in json format as below: {
name: value, name: value
}
- Parameters
std_items_file (
str
) – File path containing the standard items in json format. Should be a dict at top level containing items with item name as key and item value as value- Returns
Returns a dict of standard items
- Return type
dict
- updateMenu()¶
Update the menu items in the popup menu. Can be overridden in child class to customize the menu
- itemClicked(value)¶
Slot called when a menu item is clicked
- Parameters
value (Any builtin jsonable type. Ex:
list
but notset
) – Value of the item
- saveItem(*_)¶
Slot called when the ‘Save’ menu item is clicked
- Parameters
value (
str
) – The value arg is not used as the actual value is got by callingget_value_func
method.
- class schrodinger.ui.qt.swidgets.SavedSMARTSManager(parent, item_clicked_func, get_value_func, std_items_file=None)¶
Bases:
schrodinger.ui.qt.swidgets.SavedItemsManager
Class that manages the user saved SMARTS
- PREF_KEY = 'smarts_edit_saved_smarts'¶
- ITEM_TYPE_TEXT = 'SMARTS'¶
- ITEM_KEY = 'SMARTS'¶
- class schrodinger.ui.qt.swidgets.InstantToolTipTableView(*args, **kwargs)¶
Bases:
PyQt6.QtWidgets.QTableView
Variation of QTableView that shows tooltips for all cells instantaniously instead of after a delay.
- __init__(*args, **kwargs)¶
- mouseMoveEvent(self, e: Optional[QMouseEvent])¶
- class schrodinger.ui.qt.swidgets.LineEditWithDisabledText(*args, disabled_text, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SLabeledEdit
Line edit that shows a specific text in disabled state, similar to disabled_checkstate in swidgets.SCheckBox
- __init__(*args, disabled_text, **kwargs)¶
Create an instance
- Parameters
disabled_text (str) – The text to show when the widget is disabled
- hasDisabledText()¶
Return whether the widget has disabled_text
- Return type
bool
- Returns
True if the widget has disabled_text, False otherwise
- changeEvent(event)¶
Overrides the parent method to save & change the text when the widget is enabled/disabled (if requested)
- forceSetText(text)¶
Change the text of the widget even if it is disabled and we are controlling the text of disabled widgets. Also sets this text to be the text when the widget re-enabled
- Parameters
text (str) – The text to set
- setText(text, only_if_valid=False)¶
Overrides the parent method to not actually change the text if the widget is disabled AND we’re controlling the text of disabled widgets. In that case, we only store the desired text for when the widget is re-enabled.
- Parameters
text (str) – The text to set in the edit
only_if_valid (bool) – Only set the text if it validates as acceptable via the edit’s validator.