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

  • UNKNOWN if the event that closed the widget is not known (this happens

    when we use the Qt.PopUp window flag to do the popup closing for us)

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

  • UNKNOWN if the event that closed the widget is not known (this happens

    when we use the Qt.PopUp window flag to do the popup closing for us)

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

  • UNKNOWN if the event that closed the widget is not known (this happens

    when we use the Qt.PopUp window flag to do the popup closing for us)

schrodinger.ui.qt.pop_up_widgets.UNKNOWN = 3

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

  • UNKNOWN if the event that closed the widget is not known (this happens

    when we use the Qt.PopUp window flag to do the popup closing for us)

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: QCloseEvent)
setup()

Subclass-specific initialization. Subclasses must implement this function.

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

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

_pop_up (PopUp) – The pop up widget

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.

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

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.

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

_pop_up (PopUp) – The pop up widget

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.

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: QWidget, index: QModelIndex)
setModelData(self, editor: QWidget, model: 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(parent, pop_up_class=None)

Bases: schrodinger.ui.qt.pop_up_widgets._AbstractButtonWithPopUp, PyQt6.QtWidgets.QPushButton

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

__init__(parent, pop_up_class=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.

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

Bases: schrodinger.ui.qt.pop_up_widgets._AbstractButtonWithPopUp, 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.

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

Bases: schrodinger.ui.qt.pop_up_widgets._AbstractButtonWithPopUp, 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

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._AbstractButtonWithPopUp, PyQt6.QtWidgets.QToolButton

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

__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

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

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-2/NB/build-134/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-2/NB/build-134/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-2/NB/build-134/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

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