schrodinger.ui.qt.pop_up_widgets module

Widgets for creating a line edit with a pop up editor. To create a new pop up editor:

  • Create a subclass of PopUp. In setup(), define and layout the desired widgets.

  • Instantiate LineEditWithPopUp for a stand-alone line edit or PopUpDelegate for a table delegate. __init__ takes the PopUp subclass as an argument.

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

Bases: enum.Enum

Different modes for pop up behavior in panels.

  • Detached: The pop up opens as a separate window, allowing it to use up

    more screen real estate than the parent window. Clicking anywhere outside of the pop-up will close it. Pop up will also close when focus is switched to a different window or application, which makes it impossible to interact with the Maestro Workspace from the pop up.

  • Contained: The pop up is drawn within the constraints of the parent

    window. Clicking outside of the pop up but in the parent window will close the pop up, but clicking in other windows or applications will not. This allows the user to interact with the Workspace while the pop up is open.

Contained = 1
Detached = 2
class schrodinger.ui.qt.pop_up_widgets.PopUpAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.Enum

Center = 1
Right = 2
schrodinger.ui.qt.pop_up_widgets.REJECT = 0

Constants representing what event triggered the closing of a popup. These enums are emitted by the popUpClosing signal. - REJECT if the user closed the pop up by pressing Esc - ACCEPT if the user closed the pop up by hitting Enter or by shifting

focus

  • ACCEPT_MULTI if the user closed the pop up by hitting Ctrl+Enter

schrodinger.ui.qt.pop_up_widgets.ACCEPT = 1

Constants representing what event triggered the closing of a popup. These enums are emitted by the popUpClosing signal. - REJECT if the user closed the pop up by pressing Esc - ACCEPT if the user closed the pop up by hitting Enter or by shifting

focus

  • ACCEPT_MULTI if the user closed the pop up by hitting Ctrl+Enter

schrodinger.ui.qt.pop_up_widgets.ACCEPT_MULTI = 2

Constants representing what event triggered the closing of a popup. These enums are emitted by the popUpClosing signal. - REJECT if the user closed the pop up by pressing Esc - ACCEPT if the user closed the pop up by hitting Enter or by shifting

focus

  • ACCEPT_MULTI if the user closed the pop up by hitting Ctrl+Enter

class schrodinger.ui.qt.pop_up_widgets.PopUp(parent)

Bases: PyQt6.QtWidgets.QFrame

The base class for pop up widgets. This class is not intended to be instantiated directly and should be subclassed. Subclasses must implement setup(). Subclasses may also emit dataChanged and popUpResized when appropriate.

Important Note: at least one strong focus widget should be part of the popup dialog, otherwise a widget’s focus policy should be set to Qt.StrongFocus in order for the popup closing behavior to execute properly.

Variables
  • dataChanged (PyQt5.QtCore.pyqtSignal) – A signal emitted when a change in the pop up should trigger a change in the contents of the line edit. This signal is emitted with the desired contents of the line edit (str).

  • popUpResized (PyQt5.QtCore.pyqtSignal) – A signal emitted when the size of the pop up changes. The line edit will respond by repositioning the pop up.

  • visibilityChanged (QtCore.pyqtSignal) – A signal emitted when the pop up is shown or hidden. Includes whether the pop up is now visible (True) or not (False).

dataChanged

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.

popUpResized

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.

visibilityChanged

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)
closeEvent(self, a0: Optional[QCloseEvent])
setup()

Subclass-specific initialization. Subclasses can re-implement this function with custom set up code.

show(self)
installPopUpEventFilter(event_filter)

Install the provided event filter on all widgets within this pop up that can receive focus.

Note

This function only installs the event filter on immediate children of this widget. As a result, keyboard events on grandchildren (or later descendant) widgets will not be handled properly. If this causes issues, the implementation will have to be modified.

Parameters

event_filter (_BasisSelectorPopUpEventFilter) – The event filter to install

subWidgetHasFocus()

Return True if any widget within the pop up has focus. False otherwise.

Note

Note that combo boxes have various list view and frame children that can receive focus (and which of these widgets can receive focus varies by OS). As a result, we check the full ancestry of the focus widget here rather than just checking it’s parent. Also note that we can’t use Qt’s isAncestorOf() function to check ancestry, since combo box drop downs are considered to be their own window and isAncestorOf() requires ancestors to be part of the same window.

estimateMaxHeight()

Return an estimate of the maximum allowable height of this pop up. This estimate is used to ensure that the pop up is positioned within the window. The default implementation uses the current size hint. Subclasses can reimplement this function if they can calculate a more accurate allowable height. This is typically only applicable if the pop up is likely to change size.

Returns

The maximum allowable height

Return type

int

estimateMaxWidth()

Return an estimate of the maximum allowable width of this pop up. This estimate is used to ensure that the pop up is positioned within the window. The default implementation uses the current size hint. Subclasses can reimplement this function if they can calculate a more accurate allowable width. This is typically only applicable if the pop up is likely to change size.

Returns

The maximum allowable width

Return type

int

lineEditUpdated(text)

Update this pop up in response to the user changing the line edit text. Note that, by default, this widget will not be able to send signals during execution of this method. This prevents an infinite loop of PopUp.lineEditUpdated and LineEditWithPopUp.popUpUpdated. To modify this behavior, subclass LineEditWithPopUp and reimplement LineEditWithPopUp.popUpUpdated.

Parameters

text (str) – The current text of the line edit

showEvent(event)

Emit a signal every time this pop up is shown.

hideEvent(event)

Emit a signal every time this pop up is hidden.

class schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin(parent, pop_up_class=None, mode=None)

Bases: object

Mixin for a widget class that should produce a popup upon clicking. Includes a framework for setting the size and position of the popup frame.

Variables

popUpClosing (PyQt5.QtCore.pyqtSignal) – A signal emitted when the pop up is closed.

The signal is emitted with:

  • REJECT if the user closed the pop up by pressing Esc

  • ACCEPT if the user closed the pop up by hitting Enter or by shifting focus

  • ACCEPT_MULTI if the user closed the pop up by hitting Ctrl+Enter

Variables

DEFAULT_POP_UP_MODE: – Default value for the mode option to the init of the base class WidgetWithPopUpMixin.

DEFAULT_POP_UP_MODE = 1
popUpClosing

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.

ALIGN_TOP = 0
ALIGN_BOTTOM = 1
ALIGN_RIGHT = 2
ALIGN_LEFT = 3
ALIGN_AUTO = 4
__init__(parent, pop_up_class=None, mode=None)
Parameters
  • parent (QObject) – Parent of the widget that brings up the pop up when clicked.

  • pop_up_class (PopUp) – Class definition of the pop up.

  • mode (PopUpMode) – Pop Up mode (PopUpMode.Contained or PopUpMode.Detached)

setPopUpClass(pop_up_class)

If a pop up class was not specified via the constructor, use this method to set it after the fact. Useful for placing widgets into *.ui files.

setPopUp(pop_up)

Set the pop up widget to the specified pop up widget instance.

setPopupHalign(popup_halign)

Specify whether the pop up should have its right edge aligned with the right edge of the widget (ALIGN_RIGHT), have its left edge aligned with the left edge of the widget (ALIGN_LEFT), or have it’s horizontal alignment determined automatically (ALIGN_AUTO). Note that this setting is moot if the widget is wider than the pop up’s size hint, as the pop up will be extended to the same width as the widget.

Parameters

popup_halign (int) – The desired horizontal alignment of the pop up. Must be one of ALIGN_RIGHT, ALIGN_LEFT, or ALIGN_AUTO.

setPopupValign(popup_valign)

Specify whether the pop up should appear above (ALIGN_TOP), below (ALIGN_BOTTOM) the widget, or have it’s vertical alignment determined automatically (ALIGN_AUTO).

Parameters

popup_valign (int) – The desired vertical alignment of the pop up. Must be either ALIGN_TOP, ALIGN_BOTTOM, or ALIGN_AUTO.

moveEvent(event)

Update the pop up position and size when the widget is moved

resizeEvent(event)

Update the pop up position and size when the widget is resized

popUpUpdated(text)

Whenever the pop up emits the dataChanged signal, update the widget. This function should be implemented in subclasses if required.

Parameters

text (str) – The text emitted with the dataChanged signal

property pop_up_visible
Returns

whether the pop up frame is visible to its parent

Return type

bool

showEvent(event)

Update the pop up position and size when the widget is shown

class schrodinger.ui.qt.pop_up_widgets.LineEditWithPopUp(parent, pop_up_class)

Bases: schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, PyQt6.QtWidgets.QLineEdit

A line edit with a pop up that appears whenever the line edit has focus.

DEFAULT_POP_UP_MODE = 1
__init__(parent, pop_up_class)
Parameters
  • parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget

  • pop_up_class (type) – The class of the pop up widget. Should be a subclass of PopUp.

focusInEvent(event)

When the line edit receives focus, show the pop up

mousePressEvent(event)

If the user clicks on the line edit and it already has focus, show the pop up again (in case the user hid it with a key press)

textUpdated(text)

Whenever the text in the line edit is changed, show the pop up and call PopUp.lineEditUpdated. The default implementation prevents the PopUp from sending signals during the execution of PopUp.lineEditUpdated. This prevents an infinite loop of PopUp.lineEditUpdated and LineEditWithPopUp.popUpUpdated.

Parameters

text (str) – The current text in the line edit

class schrodinger.ui.qt.pop_up_widgets.ComboBoxWithPopUp(parent, pop_up_class=None, mode=None)

Bases: schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, PyQt6.QtWidgets.QComboBox

A combo box with a pop up that appears whenever the menu is pressed.

DEFAULT_POP_UP_MODE = 1
showPopup(self)
hidePopup(self)
class schrodinger.ui.qt.pop_up_widgets.PopUpDelegate(parent, pop_up_class, enable_accept_multi=False)

Bases: PyQt6.QtWidgets.QStyledItemDelegate

A table delegate that uses a LineEditWithPopUp as an editor.

Variables

commitDataToSelected (PyQt5.QtCore.pyqtSignal) – Commit the data from the current editor to all selected cells. Only emitted if the class is instantiated with enable_accept_multi=True. This signal (and behavior) is not a standard Qt behavior, so the table view must manually connect this signal and respond to it appropriately. This signal is emitted with the editor, the current index, and the delegate.

commitDataToSelected

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, pop_up_class, enable_accept_multi=False)
Parameters
  • parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget

  • pop_up_class (type) – The class of the pop up widget. Should be a subclass of PopUp.

  • enable_accept_multi (bool) – Whether committing data to all selected cells at once is enabled. If True, commitDataToSelected will be emitted when the LineEditWithPopUp emits popUpClosing with ACCEPT_MULTI. If False, commitData will be emitted instead.

createEditor(parent, option, index)

Create the editor and connect the popUpClosing signal. If a subclass needs to modify editor instantiation, _createEditor should be reimplemented instead of this function to ensure that the popUpClosing signal is connected properly.

See Qt documentation for an explanation of the arguments and return value.

setEditorData(self, editor: Optional[QWidget], index: QModelIndex)
setModelData(self, editor: Optional[QWidget], model: Optional[QAbstractItemModel], index: QModelIndex)
eventFilter(editor, event)

Ignore the editor losing focus, since focus may be switching to one of the pop up widgets. If the editor including the popup loses focus, popUpClosed will be called.

See Qt documentation for an explanation of the arguments and return value.

popUpClosed(editor, accept)

Respond to the editor closing by either rejecting or accepting the data. If enable_accept_multi is True, the data may also be committed to all selected rows.

Parameters
  • editor (LineEditWithPopUp) – The editor that was just closed

  • accept (int) – The signal that was emitted by the editor when it closed

class schrodinger.ui.qt.pop_up_widgets.PushButtonWithPopUp(*args, **kwargs)

Bases: schrodinger.ui.qt.pop_up_widgets._BaseButtonMixin, schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, PyQt6.QtWidgets.QPushButton

A checkable push button with a pop up that appears whenever the button is pressed.

DEFAULT_POP_UP_MODE = 2
class schrodinger.ui.qt.pop_up_widgets.PushButtonWithIndicatorAndPopUp(*args, **kwargs)

Bases: schrodinger.ui.qt.pop_up_widgets._BaseButtonMixin, schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, schrodinger.ui.qt.standard_widgets.hyperlink.ButtonWithArrowMixin, PyQt6.QtWidgets.QPushButton

A push button with a menu indicator arrow which shows a pop up when the button is pressed.

DEFAULT_POP_UP_MODE = 2
class schrodinger.ui.qt.pop_up_widgets.LinkButtonWithPopUp(*args, **kwargs)

Bases: schrodinger.ui.qt.pop_up_widgets._BaseButtonMixin, schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, schrodinger.ui.qt.standard_widgets.hyperlink.ButtonWithArrowMixin, schrodinger.ui.qt.standard_widgets.hyperlink.MenuLink

A push button that is rendered as a blue link, with a pop up that appears whenever the button is pressed. See schrodinger.ui.qt.standard_widgets.hyperlink.MenuLink

DEFAULT_POP_UP_MODE = 2
class schrodinger.ui.qt.pop_up_widgets.ToolButtonWithPopUp(parent, pop_up_class=None, arrow_type=ArrowType.UpArrow, text=None)

Bases: schrodinger.ui.qt.pop_up_widgets._BaseButtonMixin, schrodinger.ui.qt.pop_up_widgets.WidgetWithPopUpMixin, PyQt6.QtWidgets.QToolButton

A checkable tool button with a pop up that appears whenever the button is pressed.

DEFAULT_POP_UP_MODE = 2
__init__(parent, pop_up_class=None, arrow_type=ArrowType.UpArrow, text=None)
Parameters
  • parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget

  • pop_up_class (type) – The class of the pop up widget. Should be a subclass of PopUp.

  • arrow_type (Qt.ArrowType) – Type of arrow to display in the button

  • text (str) – Text to set for this button. If not specified, only an icon will be shown.

class schrodinger.ui.qt.pop_up_widgets.AddButtonWithIndicatorAndPopUp(*args, **kwargs)

Bases: schrodinger.ui.qt.pop_up_widgets.PushButtonWithIndicatorAndPopUp

PushButton with a “+” icon and “Add” text. Button also has a menu indicator which shows a pop up when clicked.

__init__(*args, **kwargs)
Parameters

parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget

class schrodinger.ui.qt.pop_up_widgets.InfoButtonWithPopUp(*args, **kwargs)

Bases: schrodinger.ui.qt.pop_up_widgets.PushButtonWithPopUp

Info Button that opens a pop up. Traditionally used to open a tooltip that contains links or more involved widgets.

INFO_BTN_STYLESHEET = '\n    QPushButton {\n        image: url(/scr/buildbot/savedbuilds/2024-4/NB/build-117/internal/lib/python3.11/site-packages/schrodinger/ui/qt/standard/icons/icon_data/info/info_lb.png);\n        border: 0px;\n        padding: 0px;\n    }\n    QPushButton::menu-indicator {\n        image: none;\n    }\n    QPushButton:hover {\n        image: url(/scr/buildbot/savedbuilds/2024-4/NB/build-117/internal/lib/python3.11/site-packages/schrodinger/ui/qt/standard/icons/icon_data/info/info_lb_hvr.png);\n    }\n    QPushButton:disabled {\n        image: url(/scr/buildbot/savedbuilds/2024-4/NB/build-117/internal/lib/python3.11/site-packages/schrodinger/ui/qt/standard/icons/icon_data/info/info_eb_alt.png);\n    }\n    '
__init__(*args, **kwargs)
Parameters

parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget