schrodinger.ui.qt.dialbox module

Contains classes for dispalying dials that allow the user to spin continuously Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.ui.qt.dialbox.Dial(parent=None, identifier='')

Bases: PyQt6.QtWidgets.QDial

This class is a modified version of the QDial. Because we are only concerned about increment or decrement of the value there’s no need for a pointer showing a ‘current’ value as in the standard Qt dial. Therefore we handle the drawing of the dial ourselves and use a series of SVG images to indicate the movement. As the value of the dial is changed we move through the array of SVG images and display the current one.

This dial only emits the dial_changed_delta signal when the mouse is dragged over it. Simply clicking on a different location in the dial has no effect.

NUM_IMAGES = 36
dial_changed_delta

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, identifier='')

Create a Dial instance

Parameters
  • parent (QWidget) – The parent widget

  • identifier (str) – The string identifier for this dial - will be emitted as part of the dial_changed_delta signals

paintEvent(event)

Redefine the paint event as we want to handle the drawing for the dial widget. This is simply a matter of displaying the current image as the index for this has already been set by sliderChanged() method.

Parameters

event (QPaintEvent) – The current QPaintEvent object

sliderChange(change)

We want to know when the value has changed. This allows us to traverse through the array of images in order to give the impression of rotation. The paintEvent() method will update the actual image.

Emits signals when the slider value changes

Parameters

change (QAbstractSlider.SliderChange enum) – enum describing what changed

sizeHint()

Redefine sizeHint() so that we by default set the widget size to the size of the SVG image.

Return type

QSize

Returns

The size hint for this widget, set to the size of the SVG image.

heightForWidth(width)

Return the width as the recommended height to keep the widget square.

Return type

int

Returns

The recommended height for this widget

mousePressEvent(event)

Reset the last_value as a sign that the user is starting to drag in the dial area

Parameters

event (QMousePressEvent) – The event object

schrodinger.ui.qt.dialbox.get_circular_delta(current_value, last_value)

Get the change between current_value and last_value, accounting for cases where the 0/360 boundary is crossed. For instance, going from 5 to 355 will have a value of -10, while going from 350 to 3 will have a value of +13.

Parameters
  • current_value (int) – The current value

  • last_value (int) – The previous value

Return type

int

Returns

The delta on going from last_value to current_value.

class schrodinger.ui.qt.dialbox.XYZDialBox

Bases: PyQt6.QtWidgets.QFrame

A class that displays a ‘virtual dialbox’ in a QFrame. The dialbox has three dials (custom widgets based on QDial), each assigned to the X, Y and Z axes of rotation.

This class has a dial_changed_delta signal that is emitted each time one of the dial changes value. The signal contains the identifier for the dial that change (‘x’, ‘y’, or ‘z’) and the delta value change.

DIAL_NAMES = ['x', 'y', 'z']
dial_changed_delta

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

Create a XYZDialBox instance

dialChangedDelta(which_dial, delta)

This method is called whenever any of the dials change value.

Parameters
  • which_dial (str) – A string identifier for the dial that changed

  • delta (int) – The amount the dial value has changed since the last time this signal was emitted during this drag event.

values()

Get the current value of all dials

Return type

list

Returns

list of ints, each item is the value of a dial