instrumentserver.gui.parameter_manager.widget#

The Parameter Manager widget (ParameterManagerGui) and the model, tree view and create form it is built from.

Classes

AddParameterWidget([parent, typeInput])

A widget that allows parameter creation.

LockableParameterWidget(parameter, ...[, parent])

The value widget of a Parameter Manager row: a ParameterWidget with the row's lock button and delete button after the value.

LocksController(gui)

The Lock behaviour of a ParameterManagerGui (plan tasks 5.3, 5.4 and 5.6): the tree's Lock column, lock buttons and read-only values, the lock and unlock actions and shortcuts, the arm strip's target pick, and the Locks panel.

ModelParameterManager(*args, **kwargs)

ParameterDeleteDelegate([parent])

ParameterManagerGui(instrument[, parent])

ParameterManagerTreeView(model, *args, **kwargs)

ProfilesManager(*args, **kwargs)

TypesController(gui)

The Type behaviour of a ParameterManagerGui (plan tasks 5.2 and 5.5): the tree's tints and gutter bands, and the Types tab's actions.

class instrumentserver.gui.parameter_manager.widget.AddParameterWidget(parent: QWidget | None = None, typeInput: bool = False)[source]#

Bases: QWidget

A widget that allows parameter creation.

Parameters:
  • parent – parent widget

  • typeInput – if True, add input fields for creating a value validator.

clear() → None[source]#
clearError() → None[source]#
invalidParamRequested#

Signal(str)

newParamRequested#

Signal(str, str, str, ParameterTypes, str)

requestNewParameter(_: bool) → None[source]#
setError(message: str) → None[source]#
class instrumentserver.gui.parameter_manager.widget.LockableParameterWidget(parameter: Any, lockButton: QPushButton, removeButton: QPushButton, parent: QWidget | None = None)[source]#

Bases: ParameterWidget

The value widget of a Parameter Manager row: a ParameterWidget with the row’s lock button and delete button after the value. It keeps the lock button so the Parameter Manager GUI can restyle it with the Lock state.

class instrumentserver.gui.parameter_manager.widget.LocksController(gui: ParameterManagerGui)[source]#

Bases: QObject

The Lock behaviour of a ParameterManagerGui (plan tasks 5.3, 5.4 and 5.6): the tree’s Lock column, lock buttons and read-only values, the lock and unlock actions and shortcuts, the arm strip’s target pick, and the Locks panel. It works on the GUI’s widgets and state and wires them in connectSignals().

armed_follower is the Follower a pick is armed for, and armed_type_lock the (Type, entry) pair a Type Lock re-target from the Types tab (plan task 5.5) is armed for; both are None while nothing is armed.

apply_locks() → None[source]#

Recompute every parameter row’s Lock state from the client-side state (plan task 5.3): the Lock column text, the lock button’s visibility, tooltip and purple fill, and whether the value renders read-only.

Runs after the state was refreshed from the Parameter Manager (on a model reload), on every pm-lock-update Broadcast, and after a parameter was created or removed by a Broadcast. Recomputing all rows on every change is fine — the tree is small — and keeps one clear path. The Locks panel is rebuilt with the same state at the end, but only while it is shown.

arm_lock(follower: str) → None[source]#

Arm the target picker for the Follower at follower: the candidates are every other parameter row of the source model, ranked like the mock’s completer (same relative path inside its Instance first), and the strip shows under the toolbar. Arming while already armed re-arms for the new Follower.

arm_type_lock(type_name: str, path: str) → None[source]#

Arm the target picker for the Type Lock of the entry path of the Type type_name (plan task 5.5): the strip shows on the Parameters tab with the entry named in its label, and the candidates are every parameter row of the source model ranked with the entry path as the relative path (the same leaf on any Instance first). Arming while already armed re-arms for the new entry.

armed_follower: str | None#
armed_type_lock: Tuple[str, str] | None#
cancel_arm() → None[source]#

Disarm the target picker without picking anything (either kind of pick: a Follower’s Lock or a Type Lock’s re-target).

connectSignals() → None[source]#
pick_lock_target(target: str) → None[source]#

Pick target as the Target of the armed pick — a Follower’s Lock (plan task 5.3) or, while a Type Lock re-target is armed, the Type Lock declaration with target as its Target (plan task 5.5). A refused Lock — a cycle (D7), a self-lock — shows the Server’s error text on the strip and stays armed so another target can be picked; a successful Lock disarms the strip, and a Type Lock declaration names the Instance parameters it skipped (D17) on the entries pane’s note.

refresh_locks_panel() → None[source]#

Rebuild the Locks panel’s rows from the client-side state (plan task 5.4): the rows from PMState.locks and PMState.types, each row’s parameter resolved through the instrument.

Runs at the end of apply_locks() and of TypesController._on_type_changed() — the Type Lock rows depend on the Types — and when the toolbar action shows the panel, but only while the panel is shown, so a hidden panel costs nothing.

class instrumentserver.gui.parameter_manager.widget.ModelParameterManager(*args: Any, **kwargs: Any)[source]#

Bases: ModelParameters

headerLabels() → List[str][source]#

The header label of every column: name, unit and delegate. A model with more columns extends this list and rowItems() together.

lockChanged#

Signal(str, object) – Emitted on a pm-lock-update Broadcast: the Follower’s path relative to the instrument, and its PMLockBluePrint (None when its Lock was removed). No model item is touched for this action.

parameter_units() → Dict[str, str][source]#

Every parameter row as {path: unit}.

rowItems(item: QStandardItem) → List[QStandardItem][source]#

The items of one row, item first, one per column of headerLabels(). insertItemTo() inserts them.

structureChanged#

Signal() – Emitted after a Broadcast changed the tree’s structure: a parameter was created or removed, or a parameter-update/parameter-call added a row the model did not know. The Parameter Manager GUI recomputes the Type claims that the tints and gutter bands show.

typeChanged#

Signal(str, object) – Emitted on a pm-type-update Broadcast: the Type’s name (the part after the instrument name), and its PMTypeBluePrint (None when the Type was removed). No model item is touched for this action.

updateParameter(bp: ParameterBroadcastBluePrint) → None[source]#
class instrumentserver.gui.parameter_manager.widget.ParameterDeleteDelegate(parent: QObject | None = None)[source]#

Bases: ParameterDelegate

makeParameterWidget(item: QStandardItem, parent: QWidget) → ParameterWidget[source]#

The editor widget for the parameter of item. A delegate that adds buttons next to the value overrides this; createEditor() does the rest (registering the widget and installing the navigation filter).

makeRemoveWidget(fullName: str, widget: QWidget) → QPushButton[source]#
make_lock_widget(fullName: str, widget: QWidget) → QPushButton[source]#

The per-row lock button. It stays hidden until the row carries a Lock (a Lock-less row shows no button, as the mock), fills purple while the Lock is locked, and only LocksController.apply_locks() changes its state.

removeParameter#

Signal(str) Emits the name of the parameter to be deleted when the user presses the delete button.

toggleLock#

Signal(str) Emits the name of the parameter whose lock button the user pressed; the Parameter Manager GUI toggles that parameter’s Lock.

class instrumentserver.gui.parameter_manager.widget.ParameterManagerGui(instrument: ProxyInstrumentModule | ParameterManager, parent: QWidget | None = None, **kwargs: Any)[source]#

Bases: InstrumentParameters

addParameter(fullName: str, value: Any, unit: str) → None[source]#
changeEvent(event: QEvent | None) → None[source]#

Re-tint the tree and the Types pane when the application switches between a light and a dark theme (the tints are stored on the rows, so they do not follow the palette on their own).

connectSignals() → None[source]#

Connects all the signals to slots of different classes. Override to add more signals

loadFromFile(loadFile: str | None = None) → None[source]#
loadProfile() → None[source]#
makeToolbar() → QToolBar[source]#

Creates the toolbar, override to add more buttons to the toolbar.

parameterCreated#

Signal() – emitted when a parameter was created successfully

parameterCreationError#

Signal(str) – emitted when there’s an error during parameter creation.

refreshAll() → None[source]#
removalDialog: QMessageBox | None#
removeParameter(fullName: str) → None[source]#

Remove the parameter at fullName (the row’s delete button and the delete_item shortcut both land here).

While the parameter is the Target of Locks — deleting it drops them (D3) — a QMessageBox names every Follower that will lose its Lock and asks for confirmation (plan task 5.6); Cancel returns without touching the Server. A parameter without Followers is removed without a dialog.

saveToFile() → None[source]#
class instrumentserver.gui.parameter_manager.widget.ParameterManagerTreeView(model: QAbstractItemModel, *args: Any, **kwargs: Any)[source]#

Bases: ParametersTreeView

delegate: ParameterDeleteDelegate#
delegateClass#

alias of ParameterDeleteDelegate

lockToRequested#

Signal(str) Emitted when the user picks “Lock to…” in the context menu; the Parameter Manager GUI arms the target picker for that parameter.

setupColumns() → None[source]#

Set up the delegates and header of any columns beyond name, unit and value. Runs before the persistent editors are opened; the default does nothing.

unlockRequested#

Signal(str) Emitted when the user picks “Unlock” in the context menu.

class instrumentserver.gui.parameter_manager.widget.ProfilesManager(*args: Any, **kwargs: Any)[source]#

Bases: QComboBox

indexChanged#

Signal() Emitted when the selected index changed.

onCurrentIndexChanged(index: int) → None[source]#
refresh() → None[source]#
class instrumentserver.gui.parameter_manager.widget.TypesController(gui: ParameterManagerGui)[source]#

Bases: QObject

The Type behaviour of a ParameterManagerGui (plan tasks 5.2 and 5.5): the tree’s tints and gutter bands, and the Types tab’s actions. It works on the GUI’s widgets and state and wires them in connectSignals().

apply_tints() → None[source]#

Recompute every row’s Type claims and repaint the tints and gutter bands (plan task 5.2).

Runs after the state was refreshed from the Parameter Manager (on a model reload), on every pm-type-update Broadcast, and after a parameter was created or removed by a Broadcast, since matching depends on which parameters exist. The Types pane rebuilds from the same state at the end (plan task 5.5).

connectSignals() → None[source]#
refresh_types_pane() → None[source]#

Rebuild the Types pane’s three panes from the client-side state (plan task 5.5): the Types, the model’s parameter rows and the tint palette.

Runs at the end of apply_tints() — so a refresh, a profile load, a pm-type-update Broadcast and a structural Broadcast all refresh it — and after every pane action’s Server call returns (the Broadcast arrives on top of that; a double rebuild is fine). The pane keeps the selected Type across rebuilds and drops the selection when the Type is gone.