schrodinger.application.matsci.stage_widgets module

class schrodinger.application.matsci.stage_widgets.BaseTogglableCellWidget(layout=None, layout_type=None)

Bases: schrodinger.ui.qt.swidgets.SFrame

Base class for creating widgets that should be added the cell of the table. Subclass it to create custom widgets with edit and display mode switch when table row is clicked.

__init__(layout=None, layout_type=None)

Create BaseTogglableCellWidget instance.

Parameters

layout (QLayout) – Layout to place this widget into.

createDisplayModeWidgets()

Override this method to add display mode widgets.

createEditModeWidgets()

Override this method to add edit mode widgets.

setDisplayMode(display)

Implement this method to switch between display and edit mode. Raise NotImplementedError to avoid switch between modes.

:param bool displayTrue if display mode widgets should be visible.

False to show the edit mode widgets.

toggleMode()

Toggle between edit and displat mode widgets. Display state of one of the edit mode widget should be checked to toggle visibility.

reset()

Reset both display and edit mode widgets.

class schrodinger.application.matsci.stage_widgets.BaseTableWidgetDefinition

Bases: object

Subclass this class to define header, column stretch, header style and widget for each column cell. Pass the subclass name to MultiRowArea class as kwarg.

INDEX_COLUMN_NAME = '#'
HEADERS = ['#']
HEADER_STYLE = 'background-color: #cccccc; font-weight: bold;'
__init__()

Create instance of this class

COLUMN_STRETCH = None
len()

Get headers count

Return type

int

Returns

length of HEADERS list

getHeader(column_index)

Get the columnn header

Parameters

column_index (int) – Index of the column to get the header

Return type

str

Returns

Header name

getStretch(column_index)

Get the column header

Parameters

column_index (int) – Index of the column to get the header

Return type

str

Returns

Header name

getWidget(column_name, row_index=0, is_header=False)

Define widgets for header cells and row cells.

Parameters
  • column_name (str) – Column header label to get the widget for

  • row_index (int) – Row index to be shown in index column

  • is_header (bool) – True to get the header widgets. False to get the general row widgets. Default is False.

  • master (QWidget) – The parent widget

Return type

QWidget

Returns

Returns widget for the header cells and row cells.

class schrodinger.application.matsci.stage_widgets.RowFrame(master, layout=None, row_index=None, button_labels=None, table_definition=None)

Bases: schrodinger.ui.qt.swidgets.SFrame

Class for single row stage in MultiRowArea. Frame with grid layout to add cell widgets and control buttons.

EVEN_ROW_STYLE = 'background-color: #ffffff;'
ODD_ROW_STYLE = 'background-color: #f0f0f0;'
HIGHLIGHT_STYLE = ' SFrame, SLabel {background-color: rgba(149, 188, 243, 150);}'
deleteRowSignal

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.

rowSelectedSignal

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, layout=None, row_index=None, button_labels=None, table_definition=None)

Create a RowFrame class instance.

Parameters
  • master (QWidget) – the object that owns this panel.

  • layout (QLayout) – Layout to place this widget into.

  • row_index – Unique row index for this row to identify.

  • button_labels (list) – A list of module constants indicating which icons should be made into control buttons. Only DELETE button is currently supported.

  • table_definition (BaseTableWidgetDefinition) – Object instance with header informations and widgets defined for each cell.

createWidgets()

Override this class add widgets defined for each column in BaseTableWidgetDefinition class into cell of table grid layout.

addWidgetToCell(widget, col_index)

Add widget to cell of the grid layout. Apply column stretch and set style sheet for each cell.

Parameters
  • widget (QWidget) – Widget to add into cell

  • col_index (int) – columnn index of the cell

addControlButtons(layout)

Add requested control buttons in last column of the row.

Parameters

layout (QLayout) – Grid layout of the row where widgets and control buttons are added.

delete()

Emit signal with row index to request the deletion from master object.

validateWidgetsCount()

Asserts if widgets count should be same as the number of columns in the grid layout.

toggleRow(highlight=True, display=False)

Select the current row by applying the highlight style and switch widgets into editing mode. Emits signal with row index to keep the track of currently selected row in master object.

Parameters
  • highlight (bool) – True for selecting and highlighting the row. False for deselecting the row.

  • display (bool) – True if display mode widgets should be visible. False to show the edit mode widgets.

updateIndex(row_index)

Update the row index of current row and show in index widget.

Parameters

row_index (int) – Updated row index for current row.

applyStyle(widget, highligh=False)

Apply style to widgets.

Parameters
  • widget (QWidget) – Widget to apply the style.

  • highlight (bool) – True for applying the highlight styleSheet. False for applying generic to styleSheet.

reset()

Reset the widgets for this row.

class schrodinger.application.matsci.stage_widgets.MultiRowArea(layout=None, row_class=<class 'schrodinger.application.matsci.stage_widgets.RowFrame'>, table_definition=<class 'schrodinger.application.matsci.stage_widgets.BaseTableWidgetDefinition'>, start_staged=True, button_labels=None)

Bases: schrodinger.ui.qt.swidgets.SFrame

Class for MultiRowArea where row stage frame objects are added. Implements QGrid layout for headers, QScrollArea for row frames. Column names, stretch, and header style should be defined as class constants.

__init__(layout=None, row_class=<class 'schrodinger.application.matsci.stage_widgets.RowFrame'>, table_definition=<class 'schrodinger.application.matsci.stage_widgets.BaseTableWidgetDefinition'>, start_staged=True, button_labels=None)

Create MultiRowArea class instance.

Parameters
  • layout (QLayout) – Layout to add this widget into.

  • row_class (RowFrame) – The class used to create new row frames.

  • table_definition (BaseTableHeaderDefinition) – Class object which defines header labels, header stretch and header widgets.

  • start_staged (bool) – Whether or not resetting this widget should populate the area with a row. Defaults to True.

  • button_labels – A set of module constants indicating which icons should be made into control buttons. Only DELETE button is currently supported.

setHeader()

Create the header row for table based on header data defined as class constant.

addRow()

Add new row object to scroll area.

selectRow(row_index)

Call to select the row with passed index and deselect the last selected row tracked in self.last_selected_row and update it with newly selected row index.

Parameters

row_index (int) – Row index for the currently selected row.

deleteRow(row_index)

Delete the row with passed row_index and update row indexes. Also selects the next row after deleted one.

Parameters

row_index (int) – Row index for the currently selected row.

updateRowIndexes(start_at=0)

Update row index starting from start_at.

Parameters

start_at (int) – All rows from this row to the end of the rows list will be updated

getRowIndex(row=None)

Return which row number this is

Parameters

row (RowFrame) – Returns the index for this row in the row list

Return type

int

Returns

The row number (starting at 0)

reset()

Reset this widget