schrodinger.application.models.gui.experimental_px.delegates.base module

Base delegate for styled item views with button tracking.

Provides painting pipeline (background + content), inline editor lifecycle (create, commit, close via Enter/Escape), cursor management (per-cell cursor based on editability and button hover), and button tracking (inert unless subclass implements _getButtonUnderMouse).

class schrodinger.application.models.gui.experimental_px.delegates.base.DelegateBase(parent: QObject = None, draw_separator: bool = True)

Bases: QItemDelegate

Base delegate for styled item views.

Subclasses should override:

  • _paintContent to customize cell rendering (receives the content rect after margins are applied)

  • _createEditorWidget to provide an inline editor widget

  • _getButtonUnderMouse to define hit-test regions for clickable buttons (called on every mouse move and press over the cell)

  • _handleButtonClick to respond when a button click completes (press and release on the same button)

__init__(parent: QObject = None, draw_separator: bool = True)
paint(self, painter: Optional[QPainter], option: QStyleOptionViewItem, index: QModelIndex)
getTextColor(index: QModelIndex) QColor

Return the text color for the given cell.

Default: muted for non-editable cells, default otherwise. Subclasses can override for custom color logic.

sizeHint(self, option: QStyleOptionViewItem, index: QModelIndex) QSize
createEditor(parent: QWidget, option: QStyleOptionViewItem, index: QModelIndex) PyQt6.QtWidgets.QWidget | None

Create an inline editor using _createEditorWidget.

updateEditorGeometry(editor: QWidget, option: QStyleOptionViewItem, index: QModelIndex) None

Position the editor vertically centered in the cell.

eventFilter(obj: QObject, event: QEvent) bool

Handle editor key presses, button tracking, and cursor updates.

clearInteractionState(view: QAbstractItemView) None

Clear all transient interaction state (button tracking and cursor).

Called by routing delegates when this delegate is no longer the active target.

installButtonTracking()

Install event filter on viewport for button tracking.

Idempotent — safe to call multiple times (e.g., from paint()).

getButtonState(index: QModelIndex, key: Hashable) State

Return the visual state of a button for PanelX rendering APIs.

Parameters:
  • index – The cell containing the button

  • key – Identifier for the button

Returns:

State.Pressed, State.Hovered, State.Disabled, or State.Default

helpEvent(event: QHelpEvent, view: QAbstractItemView, option: QStyleOptionViewItem, index: QModelIndex) bool

Show cell tooltip or fall back to model’s ToolTipRole.