schrodinger.application.matsci.gutils module¶
Module for gui utility classes and functions
Copyright Schrodinger, LLC. All rights reserved.
- schrodinger.application.matsci.gutils.validate_child_widgets(child_widgets)¶
Runs each widget’s validators while respecting the validation_order across all other widgets.
Rather than running validators one widget at a time, ensures that the validator with smallest validation_order across widgets is run first, and so on.
Validation methods that call this function and return its value should be decorated with @validation.multi_validator()
- Parameters
child_widgets (list) – The widgets to run validations for
- Return type
- Returns
The results of validations, or the results up to and including the first failed validation.
- schrodinger.application.matsci.gutils.format_tooltip(tip, min_width=None)¶
Return a formatted tooltip.
- Parameters
tip (str) – the tip text
min_width (int or None) – the minimum tip width, if None a default is used
- Return type
str
- Returns
the formatted tool tip
- schrodinger.application.matsci.gutils.load_job_into_panel(entry_id, panel, load_func)¶
Load the entry’s job into the panel
- Parameters
entry_id (int) – The entry to get source path from
panel (af2.App) – The panel to load the job into
load_func (callable) – The panel method to call to load the job
- Return bool
Whether loading was successful
- schrodinger.application.matsci.gutils.load_entries_for_panel(*entry_ids, panel=None, load_func=None, included_entry=False, selected_entries=False, load_job=False)¶
- Parameters
entry_ids (tuple) – Entry ids to load into the panel
panel (af2.App) – The panel to populate
load_func (callable) – The panel method to call to load the entries
included_entry (bool) – Whether the group’s entries should be included for the panel
selected_entries (bool) – Whether the group’s entries should be selected for the panel
load_job (bool) – Whether the entry’s job should be loaded into the panel
- Raises
RuntimeError – If neither included nor selected entries is being used
- schrodinger.application.matsci.gutils.add_desmond_ms_logo(layout, **kwargs)¶
Add a Desmond D. E. Shaw logo on the left and a MatSci logo on the right
- Parameters
layout (QBoxLayout) – The layout to add the logos to
- schrodinger.application.matsci.gutils.sub_formula(formula)¶
Add <sub></sub> tags around numbers. Can be used to prettify unit cell formula.
- Parameters
formula (str) – Formula to add tags around numbers
- Return type
str
- Returns
Formula with tags added
- schrodinger.application.matsci.gutils.color_text(value, color)¶
Return a string that colors the given value when placed in a widget (for widgets that support rich text).
- Parameters
value – The value to color. Will be converted with standard f-string conversion for its type.
color (str) – The color. Can be either a simple color name like “red” or a hexadecimal RGB value like #007732.
- Return type
str
- Returns
The rich text with the indicated color
- schrodinger.application.matsci.gutils.get_row_from_pt(maestro, entry_id)¶
Get row from the PT from entry_id
- Parameters
entry_id (str) – Entry ID
maestro (maestro) – Maestro instance
- Return type
ProjectRow or None
- Returns
Row or None, if not found
- class schrodinger.application.matsci.gutils.WheelEventFilterer¶
Bases:
PyQt6.QtCore.QObject
An event filter that turns off wheel events for the affected widget
- eventFilter(unused, event)¶
Filter out mouse wheel events
- Parameters
unused (unused) – unused
event (QEvent) – The event object for the current event
- Return type
bool
- Returns
True if the event should be ignored (a Mouse Wheel event) or False if it should be passed to the widget
- __init__(*args, **kwargs)¶
- blockSignals(self, b: bool) bool ¶
- childEvent(self, a0: QChildEvent)¶
- children(self) List[QObject] ¶
- connectNotify(self, signal: QMetaMethod)¶
- customEvent(self, a0: QEvent)¶
- deleteLater(self)¶
- destroyed¶
destroyed(self, object: typing.Optional[QObject] = None) [signal]
- disconnect(a0: QMetaObject.Connection) bool ¶
- disconnect(self) None
- disconnectNotify(self, signal: QMetaMethod)¶
- dumpObjectInfo(self)¶
- dumpObjectTree(self)¶
- dynamicPropertyNames(self) List[QByteArray] ¶
- event(self, a0: QEvent) bool ¶
- findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject ¶
- findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
- findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject] ¶
- findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
- inherits(self, classname: str) bool ¶
- installEventFilter(self, a0: QObject)¶
- isSignalConnected(self, signal: QMetaMethod) bool ¶
- isWidgetType(self) bool ¶
- isWindowType(self) bool ¶
- killTimer(self, id: int)¶
- metaObject(self) QMetaObject ¶
- moveToThread(self, thread: QThread)¶
- objectName(self) str ¶
- objectNameChanged¶
objectNameChanged(self, objectName: str) [signal]
- parent(self) QObject ¶
- property(self, name: str) Any ¶
- pyqtConfigure(...)¶
Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.
- receivers(self, signal: PYQT_SIGNAL) int ¶
- removeEventFilter(self, a0: QObject)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setObjectName(self, name: str)¶
- setParent(self, a0: QObject)¶
- setProperty(self, name: str, value: Any) bool ¶
- signalsBlocked(self) bool ¶
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int ¶
- staticMetaObject = <PyQt6.QtCore.QMetaObject object>¶
- thread(self) QThread ¶
- timerEvent(self, a0: QTimerEvent)¶
- tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str ¶
- schrodinger.application.matsci.gutils.turn_off_unwanted_wheel_events(widget, combobox=True, spinbox=True, others=None)¶
Turns off the mouse wheel event for any of the specified widget types that are a child of widget
Note: The mouse wheel will still scroll an open pop-up options list for a combobox if the list opens too large for the screen. Only mouse wheel events when the combobox is closed are ignored.
- Parameters
widget (QtWidgets.QWidget) – The widget to search for child widgets
combobox (bool) – True if comboboxes should be affected
spinbox (bool) – True if spinboxes (int and double) should be affected
others (list) – A list of other widget classes that should be affected
- schrodinger.application.matsci.gutils.run_parent_method(obj, method, *args)¶
Try to call a function of a parent widget. If not found, parent of the parent will be used and so on, until there are no more parents.
*args
will be passed to the found function (if any).- Parameters
obj (QWidget) – QWidget to use
method (str) – Method name to be called
- schrodinger.application.matsci.gutils.locate_file_from_link(row, linkprop='s_j_Jaguar_output_file', fix_link=True, parent=None, ext='.out', idtag='locate_file', caption='Locate File', source_subdir=None)¶
Locate the the requested file from the given project row property. If it isn’t at the linked location, check the source directory for this row. If it still can’t be found, a file dialog will be posted for the user to locate it.
- Parameters
row (
schrodinger.structure.Structure
orschrodinger.project.ProjectRow
) – The project row or structure with the infolinkprop (str) – The property that gives the file link
fix_link (bool) – If True, the linkprop will be fixed with any new file location found
parent (QWidget) – Any file dialog will be centered over this widget. If not given, no file dialog will be posted.
ext (str) – The extension (including ‘.’) of the file. Used only by the file dialog.
idtag (str) – The id for the file dialog
caption (str) – The caption for the file dialog
source_subdir (str) – If given and the source directory property is used to locate the file, look in this subdirectory of the source directory. If source_subdir is simply True, then if file doesn’t exists in the current directory, the subdir name is taken from the final directory in the path obtained from linkprop. For instance, if source_subdir=True and the path obtained from linkprop is /a/b/c/d, d will be the file name and c will be the source_subdir. If the source path is used and found to be /e/f/g, the file looked for will be /e/f/g/c/d.
- Return type
str or None
- Returns
The path to the file if found, otherwise None
- schrodinger.application.matsci.gutils.fill_table_with_data_frame(table, data_frame)¶
Fill the passed QTableWidget with data from the passed pandas data frame
- Parameters
table (QTableWidget) – The table to fill
data_frame (pandas.DataFrame) – The data frame to read values from
- schrodinger.application.matsci.gutils.disable_table_sort(table)¶
CM to disable sorting on a table.
- Parameters
table (QTableWidget) – the table
- schrodinger.application.matsci.gutils.shrink_panel(panel)¶
Shrinks the panel when removing widgets so that blank space is removed. Doesn’t not work on Mac.
- Parameters
panel (af2.BasePanel) – The panel to shrink
- schrodinger.application.matsci.gutils.remove_spacers(layout, orientation=None)¶
Remove all spacer items from the given layout and any layout it contains
- Parameters
layout (QtWidgets.QLayout) –
orientation (str or Qt.Orientation) – The orientation of the spacer to remove. Should be either
swidgets.VERTICAL
orswidgets.HORIZONTAL
, or a Qt.Orientation enum
- schrodinger.application.matsci.gutils.expected_text_width(widget, text=None, chars=None)¶
Get the expected width of some text given the widget’s font settings
- Parameters
widget (QWidget) – The widget the text will display on
text (str) – The exact text to display
chars (int) – The number of characters that will be displayed. An average width for this many characters will be return.
- Return type
int
- Returns
The expected width of the given text when displayed on widget
- schrodinger.application.matsci.gutils.add_maestro_banner(text, text2='', action='', command='', action2='', command2='', action_in_new_line=False)¶
Add a temporary Maestro banner at the top of the Workspace. Supports adding clickable hyperlinks with actions
- Parameters
text (str) – The banner text
See Prototype::addPythonBanner() in mmshare/maestro/src/main/prototype.h for other arguments
- schrodinger.application.matsci.gutils.get_matplotlib_toolbar_message(event)¶
Get the toolbar message based on the mouse event
- Parameters
event (matplotlib.backend_bases.MouseEvent) – Contains information about the location of the cursor and above which
matplotlib.axes.Axes
object the cursor was at the time of the event, if any.- Return str
The toolbar message
- schrodinger.application.matsci.gutils.subscript_chemical_formula(formula)¶
Subscript all numbers in a string. Used to make chemical formulas look prettier.
- Parameters
formula (str) – The chemical formula you want to format, e.g., ‘H2O’
- Return str
The subscripted chemical formula, e.g., ‘H<sub>2</sub>O’
- schrodinger.application.matsci.gutils.subscript_cg_formula(formula)¶
Subscript numbers in a string that follow closing parentheses. Used to make chemical formulas for coarse-grain structures look prettier.
- Parameters
formula (str) – The chemical formula you want to format, e.g., ‘(W)80(BENZ)20)’
- Return str
The subscripted chemical formula, e.g., ‘(W)<sub>80</sub>(BENZ)<sub>20</sub>)’
- schrodinger.application.matsci.gutils.error(widget, msg)¶
Display an error dialog with a message
- Parameters
widget (QWidget) – Widget
msg (str) – The message to display in the error dialog
- schrodinger.application.matsci.gutils.info(widget, msg)¶
Display an information dialog with a message
- Parameters
widget (QWidget) – Widget
msg (str) – The message to display in the information dialog
- schrodinger.application.matsci.gutils.set_min_dimensions(panel, width=800, height=700)¶
Set the minimum dimensions of the panel.
- Parameters
panel (af2.App) – the panel for which the minimum dimensions will be set
width (int) – the minimum width
height (int) – the minimum height
- schrodinger.application.matsci.gutils.ignore_maestro_callbacks(attribute=None)¶
A decorator which accepts class attribute which is has ignoreMaestroCallbacks context manager
- Parameters
attribute (str) – attribute which has ignoreMaestroCallbacks context manager