stoner_measurement.plugins.command.status.StatusCommand¶
- class stoner_measurement.plugins.command.status.StatusCommand(parent=None)[source]¶
Bases:
CommandPluginUpdate the application status bar with a custom message.
Use this command when you want to show progress or context information to the user while a sequence is running. Typical examples include indicating the current step, the current scan index, or a short description of the stage the sequence is entering.
In the configuration panel, set the status expression to the text you want to appear in the status bar. This can be a fixed string or a Python expression that uses current sequence variables, for example:
"f'Step {step_index} of {total_steps} complete'"
When the step runs, the resolved text is sent to the application’s status bar.
The configuration tab contains the standard instance-name field together with the status expression editor. The Help/About tab uses this docstring to explain how the expression is evaluated and how the resulting text is routed to the application’s status display.
- Variables:
status_expr (str) – Python expression string that evaluates to the status text. Defaults to
"'Ready'".status_message (pyqtSignal[str]) – Emitted by
execute()with the resolved status string. Automatically connected to the engine’sstatus_changedsignal when the plugin is attached to aSequenceEngine. Theexecute()and__call__()methods also accept an optional keyword parameterstatusthat overrides the evaluatedstatus_exprfor that call.instance_name (str) – Inherited Python identifier for this instance in the Script tab and QtConsole.
comment (str) – Inherited optional note displayed beside this step.
sequence_engine (SequenceEngine | None) – Inherited owning engine and its live namespace; None while detached.
- Keyword Parameters:
parent (QObject | None) – Optional Qt parent object.
Examples
With an instance named
statusin the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:status.status_expr = "f'Point {counter.ix} complete'"
- config_widget(parent: QWidget | None = None) QWidget[source]¶
Return a settings widget with a status-expression editor.
Displays a
QFormLayoutcontaining aQLineEditthat accepts a Python expression string for the status message, and a brief description label.- Keyword Parameters:
parent (QWidget | None) – Optional Qt parent widget.
- Returns:
The settings widget for the Settings tab.
- Return type:
(QWidget)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.status import StatusCommand >>> from qtpy.QtWidgets import QWidget >>> isinstance(StatusCommand().config_widget(), QWidget) True
- execute(*, status: str | None = None) None[source]¶
Evaluate
status_exprand emit the result as a status message.Emits
status_messagewith the resolved string, which is automatically forwarded to the engine’sstatus_changedsignal and from there to the application status bar.- Keyword Parameters:
status (str | None) – When provided, this string is used directly as the status message, overriding the evaluated
status_exprsetting.- Raises:
RuntimeError – If the plugin is not attached to a sequence engine and
statusis not provided.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.status import StatusCommand >>> from stoner_measurement.core.sequence_engine import SequenceEngine >>> engine = SequenceEngine() >>> cmd = StatusCommand() >>> engine.add_plugin("status", cmd) >>> received = [] >>> engine.status_changed.connect(received.append) >>> cmd.execute(status="Running step 1") >>> received[-1] 'Running step 1' >>> engine.shutdown()
- property name: str¶
Unique identifier for the status command.
- Returns:
"Status".- Return type:
(str)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.status import StatusCommand >>> StatusCommand().name 'Status'
- property sequence_engine: SequenceEngine | None¶
Active sequence engine, or
Nonewhen the plugin is detached.Overrides the class-level attribute from
BasePluginwith a full property so that the setter can automatically connect thestatus_messagesignal to the engine’sstatus_changedsignal whenever the engine reference changes.- Returns:
The owning engine, or
Noneif not attached.- Return type:
(SequenceEngine | None)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.status import StatusCommand >>> from stoner_measurement.core.sequence_engine import SequenceEngine >>> engine = SequenceEngine() >>> cmd = StatusCommand() >>> cmd.sequence_engine is None True >>> engine.add_plugin("status", cmd) >>> cmd.sequence_engine is engine True >>> engine.shutdown()
- status_message¶
Signal emitted by execute() — the resolved status string.
- to_json() dict[str, Any][source]¶
Serialise the status command configuration to a JSON-compatible dict.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.status import StatusCommand >>> d = StatusCommand().to_json() >>> d["type"] 'command' >>> "status_expr" in d True