UI modules¶
Main window widget — assembles the tabbed layout.
- class stoner_measurement.ui.main_window.MainWindow(plugin_manager: PluginManager, parent: QWidget | None = None, *, display_registry=None, display_factory_id: str | None = None, display_settings=None)[source]¶
Bases:
QWidgetCentral widget that provides the tabbed layout.
Contains two tabs:
Measurement — the three-panel layout (DockPanel | PlotDisplayHost | ConfigPanel).
Script Editor — a Python editor and interactive console.
Layout of the Measurement tab (left → right):
DockPanel — 25 % of width, instrument / sequence control.
PlotDisplayHost — 50 % of width, selected measurement display.
ConfigPanel — 25 % of width, tabbed configuration.
- Parameters:
plugin_manager (PluginManager) – Shared plugin manager instance.
- Keyword Parameters:
parent (QWidget | None) – Optional parent widget.
display_registry (PlotDisplayRegistry | None) – Startup display factories; discover installed factories when omitted.
display_factory_id (str) – Startup factory ID, with Cartesian fallback on selection failure.
display_settings (QSettings | None) – Optional versioned display preferences, excluding measurement arrays.
- Variables:
dock_panel (DockPanel) – Left panel of the Measurement tab.
plot_display_host (PlotDisplayHost) – Stable main display host and service.
plot_widget (QWidget) – Concrete display for GUI inspection and legacy access.
config_panel (ConfigPanel) – Right configuration panel.
script_tab (ScriptTab) – The Script Editor tab widget.
- property config_panel: ConfigPanel¶
Right configuration panel (Measurement tab).
- Returns:
The configuration panel widget.
- Return type:
- property dock_panel: DockPanel¶
Left dock panel (Measurement tab).
- Returns:
The dock panel widget.
- Return type:
- property plot_display_host: PlotDisplayHost¶
Stable host and producer service for the main measurement display.
- property plot_widget: QWidget¶
Concrete display widget; Cartesian compatibility and GUI inspection.
- Returns:
The selected display’s widget (PlotWidget for Cartesian).
- Return type:
(QWidget)
- property script_tab: ScriptTab¶
The Script Editor tab widget.
- Returns:
The script tab widget.
- Return type:
(ScriptTab)
- property sequence_tabs: QTabBar¶
Tab bar representing the open measurement-sequence documents.
- property tabs: QTabWidget¶
The top-level tab widget containing all tabs.
- Returns:
The tab widget.
- Return type:
(QTabWidget)
Dock panel — left 25 % of the main window.
Provides plugin listing, sequence building controls, a run button,
and a monitoring section where plugins can display live status widgets.
The sequence list is a tree widget that supports drag-and-drop reordering
and arbitrarily deep sub-sequence nesting for
SequencePlugin items
(including StateControlPlugin),
enabling multi-dimensional measurement scans. Plugins may also be dragged
directly from the Available sequence commands list into the sequence tree to
insert new steps at any position or into a sub-sequence.
- class stoner_measurement.ui.dock_panel.DockPanel(plugin_manager: PluginManager, parent: QWidget | None = None)[source]¶
Bases:
QWidgetLeft panel containing instrument, sequence controls, and monitoring widgets.
Plugins may contribute a live-status widget via
monitor_widget(). Those widgets are displayed in a dedicated Monitoring section at the bottom of this panel and are removed automatically when the plugin is unregistered.When the user clicks a step in the Sequence Steps tree, the
plugin_selectedsignal is emitted with the corresponding plugin instance so that the configuration panel can update itself accordingly.The sequence tree supports drag-and-drop:
Drag a step above or below another to reorder.
Drag any step onto a
SequencePluginitem (e.g. aStateControlPlugin) to nest it as a sub-step (shown with indentation). This includes dragging one sequence-plugin step onto another, enabling multi-dimensional measurement scans at arbitrary depth.Drag a sub-step to the top level to promote it.
Drag a plugin from the Available sequence commands list and drop it above, below, or onto any existing step (or onto the empty area below all steps) to insert a brand-new step instance at that position. Dropping onto a
SequencePluginitem adds the new step as the last child of that sub-sequence.
- Variables:
sequence_steps (list[_SequenceStep]) – The current sequence steps as a recursive structure. Each element is either a plugin instance (for a leaf step with no sub-steps) or a
(plugin_instance, [sub-steps…])tuple for aSequencePluginthat has nested children. The inner list follows the same_SequenceStepstructure, so nesting may be arbitrarily deep.- Parameters:
plugin_manager (PluginManager) – The application
PluginManagerinstance — used to populate the available-plugins list and to manage monitoring widgets.- Keyword Parameters:
parent (QWidget | None) – Optional Qt parent widget.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.sequence_steps []
- add_monitor_widget(plugin_name: str, widget: QWidget) None[source]¶
Add a monitoring widget for the named plugin.
If a monitoring widget for plugin_name is already present this call is a no-op.
- Parameters:
plugin_name (str) – Unique identifier for the owning plugin.
widget (QWidget) – The widget to display in the monitoring section.
Examples
>>> from qtpy.QtWidgets import QApplication, QLabel >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.add_monitor_widget("test", QLabel("Status: OK")) >>> "test" in panel.monitor_widgets True
- copy_selected_step() bool[source]¶
Copy the selected sequence step(s) as system-clipboard JSON.
All selected steps (including any sub-steps) are serialised to JSON and published as plain text and
application/json. A retained copy is also stored in_clipboard_step_json. When a selected item’s parent is also selected the child is omitted because its data is already captured inside the parent’s serialised sub-steps. ReturnsFalsewhen nothing is selected.- Returns:
Trueif at least one step was copied,Falseif nothing was selected.- Return type:
(bool)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.load_sequence([DummyPlugin()]) >>> panel._sequence_tree.setCurrentItem(panel._sequence_tree.topLevelItem(0)) >>> panel.copy_selected_step() True >>> panel.has_clipboard_step True
- cut_selected_step() bool[source]¶
Cut the selected sequence step(s) to the system clipboard as JSON.
Equivalent to
copy_selected_step()followed by removing all selected steps from the tree. ReturnsFalsewhen nothing is selected.- Returns:
Trueif at least one step was cut,Falseif nothing was selected.- Return type:
(bool)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.load_sequence([DummyPlugin()]) >>> panel._sequence_tree.setCurrentItem(panel._sequence_tree.topLevelItem(0)) >>> panel.cut_selected_step() True >>> panel._sequence_tree.topLevelItemCount() 0
- disabled_action_label() str[source]¶
Return the appropriate label for the disable/enable toggle action.
Inspects the currently selected sequence steps and returns
"Enable Plugin(s)"when all selected plugins are disabled, or"Disable Plugin(s)"otherwise (including when the selection is empty). The plural suffix is omitted when exactly one item is selected.- Returns:
The action label to display in the context menu or Edit menu.
- Return type:
(str)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.disabled_action_label() 'Disable Plugin'
- property has_clipboard_step: bool¶
Truewhen a valid sequence-step payload is available to paste.- Returns:
Whether there is a copied/cut step ready to paste.
- Return type:
(bool)
- load_sequence(steps: list[_SequenceStep]) None[source]¶
Replace the current sequence tree with steps.
All existing steps are removed and their plugin references released before the new steps are inserted. Each plugin is added to
_step_pluginsso that it is not garbage-collected, and itsinstance_name_changedsignal (if present) is wired to the tree’s label-update handler.This method is the programmatic counterpart of the interactive drag-and-drop sequence builder. Use it when loading a sequence from a file (see
stoner_measurement.core.serializer).- Parameters:
steps (list[_SequenceStep]) – Sequence steps in the same nested format returned by
sequence_steps.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> plugin = DummyPlugin() >>> panel.load_sequence([plugin]) >>> len(panel.sequence_steps) 1
- property monitor_widgets: dict[str, QWidget]¶
Mapping of plugin name → currently displayed monitoring widget.
- paste_step() bool[source]¶
Paste step(s) from valid system-clipboard JSON into the sequence tree.
Plain text with the canonical sequence JSON structure is accepted. A retained internal payload is used only when the system clipboard is empty. All steps are inserted immediately after the current item (at the same nesting level), preserving their original order. When nothing is selected every step is appended at the top level. Instance names are adjusted using
_compute_paste_name()to avoid collisions with existing names. All newly inserted items are selected after the paste.- Returns:
Trueif at least one step was pasted,Falsewhen the clipboard is empty.- Return type:
(bool)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.load_sequence([DummyPlugin()]) >>> panel._sequence_tree.setCurrentItem(panel._sequence_tree.topLevelItem(0)) >>> panel.copy_selected_step() True >>> panel.paste_step() True >>> panel._sequence_tree.topLevelItemCount() 2
- plugin_selected¶
Emitted with the plugin instance when exactly one sequence step is selected, or
Nonewhen the selection is cleared or multiple steps are selected simultaneously.
- remove_monitor_widget(plugin_name: str) None[source]¶
Remove the monitoring widget registered for plugin_name.
If no widget is registered for plugin_name this call is a no-op.
- Parameters:
plugin_name (str) – Unique identifier for the owning plugin.
Examples
>>> from qtpy.QtWidgets import QApplication, QLabel >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.add_monitor_widget("test", QLabel("Status: OK")) >>> panel.remove_monitor_widget("test") >>> "test" in panel.monitor_widgets False
- run_selection_requested¶
Qt signal.
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.
- property selected_sequence_steps: list[_SequenceStep]¶
Return selected roots with full sub-sequences, in tree order.
- property sequence_steps: list[_SequenceStep]¶
Return the current sequence steps as a (possibly nested) list.
Each element is either:
a plugin instance for a step that has no sub-steps, or
a
(plugin_instance, [sub-steps…])tuple for aSequencePluginstep that has at least one nested child. The inner list follows the same structure recursively, allowing arbitrarily deep nesting for multi-dimensional measurement scans.
- Returns:
Ordered sequence of step descriptors.
- Return type:
(list[_SequenceStep])
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> panel.sequence_steps []
- sequence_structure_changed¶
Qt signal.
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.
- property sequence_tabs: FontAwareTabBar¶
Tab bar representing the open measurement-sequence documents.
- toggle_disable_selected_steps() None[source]¶
Toggle the disabled state of all currently selected sequence steps.
If any selected plugin is currently enabled, all selected plugins are disabled. If all selected plugins are already disabled, they are all re-enabled. The visual appearance of each affected tree item is updated immediately to reflect the new state.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = DockPanel(plugin_manager=pm) >>> plugin = DummyPlugin() >>> panel.load_sequence([plugin]) >>> panel._sequence_tree.setCurrentItem(panel._sequence_tree.topLevelItem(0)) >>> plugin.disabled False >>> panel.toggle_disable_selected_steps() >>> plugin.disabled True >>> panel.toggle_disable_selected_steps() >>> plugin.disabled False
Central PyQtGraph plotting widget — middle 50 % of the main window.
Supports multiple named traces (each with its own colour) and multiple
independent x- and y-axes implemented via linked
pyqtgraph.ViewBox instances.
- class stoner_measurement.ui.plot_widget.AxesConfigDialog(*, x_axes: list[_AxisDialogEntry], y_axes: list[_AxisDialogEntry], on_range_changed: Callable[[str, float | None, float | None], None] | None = None, parent: QWidget | None = None)[source]¶
Bases:
QDialogDialog for configuring x/y axes on the plot widget.
- Keyword Parameters:
x_axes (list[_AxisDialogEntry]) – Existing x-axis configuration rows.
y_axes (list[_AxisDialogEntry]) – Existing y-axis configuration rows.
parent (QWidget | None) – Optional parent widget.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> dlg = AxesConfigDialog(x_axes=[], y_axes=[]) >>> dlg.windowTitle() 'Configure Axes'
- class stoner_measurement.ui.plot_widget.PlotWidget(parent: QWidget | None = None, *, show_axis_controls: bool = True, show_trace_table: bool = True)[source]¶
Bases:
QWidgetPyQtGraph-based plot area for displaying measurement data.
The widget supports:
Named traces — each trace is an independent
pyqtgraph.PlotDataItemwith its own colour. Traces are created on first use and can be updated point-by-point or in bulk.Multiple axes — additional y-axes (left or right) and x-axes (top or bottom) can be added, and individual traces can be assigned to any axis pair.
- Variables:
pg_widget (pg.PlotWidget) – The underlying
pyqtgraph.PlotWidget.- Keyword Parameters:
parent (QWidget | None) – Optional Qt parent widget.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("my_trace", 1.0, 2.0) >>> widget.x_data("my_trace") [1.0]
- add_data_marker(x: float, y: float, label: str | None = None, *, x_axis: str = 'bottom', y_axis: str = 'left') int[source]¶
Add a fixed data-coordinate marker and return its stable ID.
The optional axis names allow callers to anchor a marker to any registered x/y pair. The marker follows zooming, panning, and scale mapping changes. When label is omitted, coordinates on the active axes are shown; selecting other axes changes the label, not the anchor.
- add_x_axis(name: str, label: AxisLabel | str, position: Literal['bottom', 'top'] = 'top') None[source]¶
Add a new x-axis with an independent
pyqtgraph.ViewBox.The new ViewBox is linked to the main plot’s y-axis so that panning and zooming in y remain synchronised.
- Parameters:
- Keyword Parameters:
position (Literal[“bottom”, “top”]) – Position of the axis relative to the plot. Defaults to
"top".
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.add_x_axis("freq", "Frequency (Hz)", position="top") >>> "freq" in widget.axis_names True
- add_y_axis(name: str, label: AxisLabel | str, side: Literal['left', 'right'] = 'right') None[source]¶
Add a new y-axis with an independent
pyqtgraph.ViewBox.The new ViewBox is linked to the main plot’s x-axis so that panning and zooming in x remain synchronised across all y-axes.
- Parameters:
- Keyword Parameters:
side (Literal[“left”, “right”]) – Side of the plot on which the axis appears. Defaults to
"right".
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.add_y_axis("temperature", "Temperature (K)", side="right") >>> "temperature" in widget.axis_names True
- append_point(trace_name: str, x: float, y: float) None[source]¶
Append a single (x, y) data point to the named trace.
The trace is created automatically if it does not already exist.
- Parameters:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("sig", 0.0, 1.0) >>> widget.x_data("sig") [0.0]
- append_points(trace_name: str, x_data, y_data) None[source]¶
Append captured samples with one redraw and automatic-range update.
Values are converted before mutation. Empty updates still create the named series, matching the portable append contract.
- assign_trace_axes(trace_name: str, x_axis: str = 'bottom', y_axis: str = 'left') None[source]¶
Assign a trace to a specific pair of axes.
The trace is moved from its current
pyqtgraph.ViewBoxto the ViewBox associated with y_axis. This controls which axis range is used when the trace is rendered.- Parameters:
trace_name (str) – Name of the trace to reassign.
- Keyword Parameters:
x_axis (str) – Name of the x-axis to use (must have been created via
add_x_axis()or be"bottom"). Defaults to"bottom".y_axis (str) – Name of the y-axis to use (must have been created via
add_y_axis()or be"left"). Defaults to"left".
- Raises:
KeyError – If trace_name, x_axis, or y_axis are not registered.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.add_y_axis("temp", "Temperature (K)") >>> widget.append_point("sig", 0.0, 300.0) >>> widget.assign_trace_axes("sig", y_axis="temp")
- property axis_names: list[str]¶
Sorted list of all registered axis names (x and y combined).
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> sorted(widget.axis_names) ['bottom', 'left']
- clear_all() None[source]¶
Remove all traces, their data, and accumulated axis labels.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("a", 1.0, 2.0) >>> widget.clear_all() >>> widget.trace_names []
- ensure_x_axis(name: str, label: AxisLabel | str = '') None[source]¶
Ensure an x-axis with name exists, creating it at the top if absent.
- Parameters:
name (str) – Identifier for the x-axis. One of the default
"bottom"axis names or a custom name.- Keyword Parameters:
label (str) – Text label shown on the axis. Defaults to name when empty.
- ensure_y_axis(name: str, label: AxisLabel | str = '') None[source]¶
Ensure a y-axis with name exists, creating it on the right if absent.
If the axis already exists its label metadata is refreshed. Otherwise a new right-hand y-axis is added using
add_y_axis(), with label as the displayed axis label (falling back to name when empty).This is intended for use by command plugins that direct trace data to a named axis — they call this method before
assign_trace_axes()so that axes are created on demand without requiring the user to add them manually first.- Parameters:
name (str) – Identifier for the y-axis. One of the default
"left"axis names or a custom name.- Keyword Parameters:
label (str) – Text label shown on the axis. Defaults to name when empty.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.ensure_y_axis("temp", "Temperature (K)") >>> "temp" in widget.axis_names True >>> widget.ensure_y_axis("temp") # idempotent >>> widget.axis_names.count("temp") 1
- export_plot_settings() dict[source]¶
Capture version-one renderer preferences, excluding measurement arrays.
- import_plot_settings(settings) None[source]¶
Restore versioned renderer preferences through this widget’s public API.
- import_plot_state(state) None[source]¶
Hydrate a candidate with axes, data/errors, styles, markers and preferences.
- mark_data_update_queued() None[source]¶
Record that a plot data update has been queued for processing.
- property pg_widget: pyqtgraph.PlotWidget¶
The underlying
pyqtgraph.PlotWidget.
- plot_axis_descriptions() tuple[source]¶
Return portable axis descriptions for selectors and queued clients.
- plot_series_descriptions() tuple[source]¶
Return series identities, titles and visibility without graphics objects.
- plot_state_changed¶
Qt signal.
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.
- remove_axis(name: str) None[source]¶
Remove a non-default axis and reassign traces using it.
- Parameters:
name (str) – Registered axis name to remove.
- Raises:
KeyError – If name is unknown.
ValueError – If attempting to remove the built-in
"bottom"or"left"axis.
- remove_data_marker(marker_id: int) bool[source]¶
Remove the marker with marker_id and report whether it existed.
- remove_trace(trace_name: str) None[source]¶
Remove a named trace and all its data.
If trace_name does not exist this call is a no-op.
- Parameters:
trace_name (str) – Name of the trace to remove.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("sig", 0.0, 1.0) >>> widget.remove_trace("sig") >>> widget.trace_names []
- rename_trace(old_name: str, new_name: str) None[source]¶
Rename a trace without losing its data, axes, style, or visibility.
Missing source traces are ignored so command plugins may request a rename before their first point has been plotted. Renaming onto an existing trace is rejected to avoid silently merging or overwriting data.
- Parameters:
- Raises:
ValueError – If new_name is empty or already belongs to another trace.
- set_axis_label(name: str, label: AxisLabel | str) None[source]¶
Set the displayed title for an axis.
- set_axis_log_scale(name: str, log_scale: bool) None[source]¶
Set logarithmic scaling mode for an axis.
- set_axis_mouse_active(name: str, active: bool) None[source]¶
Select an axis for mouse pan/zoom independently of the other axes.
- set_axis_range(name: str, minimum: float | None = None, maximum: float | None = None) None[source]¶
Set the visible range for an axis with independent auto/manual bounds.
Passing
Nonefor either bound leaves that bound on auto-range while a numeric value fixes it manually.
- set_axis_scale(name: str, scale: Literal['linear', 'log', 'symlog', 'logit', 'asinh'], parameter: float = 1.0) None[source]¶
Set an axis to linear, log, symlog, logit, or asinh mapping.
- set_default_axis_labels(x_label: AxisLabel | str, y_label: AxisLabel | str) None[source]¶
Accumulate and display labels for the default bottom and left axes.
Called by
PlotTraceCommandwhen trace metadata (names and units fromTraceData) is available so that the plot axes reflect the physical quantities being displayed.- Parameters:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.set_default_axis_labels("Current (A)", "Voltage (V)") >>> widget._pg_widget.getPlotItem().getAxis("bottom").axis_label AxisLabel(label='Current', unit='A')
- set_rolling_time_window(duration_seconds: float) None[source]¶
Fix the bottom axis to a real-time window ending at the present.
Rolling controller charts express sample timestamps as negative seconds relative to the current time. Keeping this axis manual prevents the data extent and polling density from changing the apparent time scale.
- set_trace(trace_name: str, x_data: Sequence[float], y_data: Sequence[float]) None[source]¶
Replace the complete data series for a named trace.
The trace is created automatically if it does not already exist.
- Parameters:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.set_trace("sig", [0.0, 1.0], [2.0, 3.0]) >>> widget.y_data("sig") [2.0, 3.0]
- set_trace_style(trace_name: str, *, colour: str | None = None, line_style: str | None = None, point_style: str | None = None, line_width: float | None = None, point_size: float | None = None) None[source]¶
Set visual style properties for a trace.
- Parameters:
trace_name (str) – Name of the trace to style.
- Keyword Parameters:
colour (str | None) – Colour string accepted by pyqtgraph (e.g.
"#ff0000"). IfNone, the trace’s existing colour is preserved.line_style (str) – One of
"solid","dash","dot","dash-dot", or"none".point_style (str) – One of
"none","circle","square","triangle","diamond","plus", or"cross".line_width (float | None) – Width of the plotted line. If
Nonethe existing width is preserved.point_size (float | None) – Size of plotted points. If
Nonethe existing size is preserved.
- Raises:
ValueError – If line_style or point_style are unknown values.
- set_trace_style_from_dict(trace_name: str, style: dict) None[source]¶
Apply visual style properties supplied in a dict from a command plugin.
Calls
set_trace_style()using only the keys present in style that carry non-empty, non-zero values. Unknown keys are silently ignored so that callers do not need to know the exact parameter names.- Parameters:
trace_name (str) – Name of the trace to style.
style (dict) – Mapping containing any subset of
"colour","line_style","point_style","line_width", and"point_size". Empty string values and zero numeric values are treated as “use widget default” and are not forwarded toset_trace_style().
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("sig", 0.0, 1.0) >>> widget.set_trace_style_from_dict("sig", {"colour": "red", "line_style": "dash"}) >>> widget._trace_style["sig"]["colour"] '#ff0000' >>> widget._trace_style["sig"]["line"] 'dash'
- set_trace_title(trace_name: str, title: str) None[source]¶
Change a displayed title without changing the series identity.
- set_trace_visible(trace_name: str, visible: bool) None[source]¶
Public wrapper for changing trace visibility.
- set_trace_with_errors(trace_name: str, x_data: Sequence[float], y_data: Sequence[float], x_err: Sequence[float] | None, y_err: Sequence[float] | None) None[source]¶
Replace the complete data series for a named trace, including error bars.
The trace is created automatically if it does not already exist. Error bars are drawn using
pyqtgraph.ErrorBarItemwhen the supplied error arrays are non-empty and contain at least one non-zero value. If a previous error-bar item exists for trace_name it is updated in place; if the new call carries no error data the old item is removed.- Parameters:
trace_name (str) – Name of the trace to update.
x_data (Sequence[float]) – New horizontal axis data.
y_data (Sequence[float]) – New vertical axis data.
x_err (Sequence[float] | None) – Symmetric x-axis error values (half-lengths), or
None/ empty array for no x-error bars.y_err (Sequence[float] | None) – Symmetric y-axis error values (half-lengths), or
None/ empty array for no y-error bars.
Examples
>>> from qtpy.QtWidgets import QApplication >>> import numpy as np >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.set_trace_with_errors("sig", [0.0, 1.0], [2.0, 3.0], None, [0.1, 0.1]) >>> widget.y_data("sig") [2.0, 3.0]
- trace_axis_names(trace_name: str) tuple[str, str][source]¶
Return the named coordinate axes assigned to a series.
- property trace_names: list[str]¶
Sorted list of currently registered trace names.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("b", 0.0, 1.0) >>> widget.append_point("a", 0.0, 1.0) >>> widget.trace_names ['a', 'b']
- trace_style(trace_name: str) dict[str, str][source]¶
Return the current style dictionary for a trace.
- trace_uncertainties(trace_name: str) tuple[source]¶
Return owned uncertainty arrays for an existing series.
- x_data(trace_name: str = 'default') list[float][source]¶
Return the horizontal axis data for trace_name.
- Parameters:
trace_name (str) – Name of the trace. Defaults to
"default".- Returns:
Copy of the x data list.
- Return type:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("sig", 1.0, 2.0) >>> widget.x_data("sig") [1.0]
- y_data(trace_name: str = 'default') list[float][source]¶
Return the vertical axis data for trace_name.
- Parameters:
trace_name (str) – Name of the trace. Defaults to
"default".- Returns:
Copy of the y data list.
- Return type:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> widget = PlotWidget() >>> widget.append_point("sig", 1.0, 2.0) >>> widget.y_data("sig") [2.0]
- stoner_measurement.ui.plot_widget.configure_chart_legend(tree) None[source]¶
Configure a two-column chart legend to favour the trace label column.
Configuration panel — right 25 % of the main window.
A QTabWidget that displays the configuration tabs of whichever plugin
is currently selected in the sequence editor. Tabs are shown by calling
ConfigPanel.show_plugin() and cleared when no step is selected.
- class stoner_measurement.ui.config_panel.ConfigPanel(plugin_manager: PluginManager, parent: QWidget | None = None)[source]¶
Bases:
QWidgetRight-hand tabbed configuration panel.
Displays the configuration tabs of the plugin that is currently selected in the sequence editor. Call
show_plugin()to load a plugin’s tabs or passNoneto return to the idle placeholder.When the plugin manager notifies that a plugin has been removed,
show_plugin()is called withNoneautomatically if the removed plugin was the one currently being displayed.- Variables:
tabs (QTabWidget) – The underlying tab widget.
- Parameters:
plugin_manager (PluginManager) – The application
PluginManagerinstance — used to detect when the currently displayed plugin is unregistered.- Keyword Parameters:
parent (QWidget | None) – Optional Qt parent widget.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = ConfigPanel(plugin_manager=pm) >>> panel.tabs.count() 0
- property collapse_button: QToolButton¶
Button that collapses the configuration panel.
- collapsed_changed¶
Qt signal.
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.
- property collapsed_tabs: QTabBar¶
The vertical tab strip displayed while the panel is collapsed.
- commit_pending_changes() None[source]¶
Commit any pending edits in the currently displayed configuration tabs.
Some input widgets (e.g.
QLineEdit) only apply their value to the plugin when the widget loses focus or the user presses Return. Toolbar and menu actions that do not take keyboard focus (the default Qt behaviour for toolbar buttons) would otherwise bypass this mechanism, so unsaved text would not reach the plugin before the action executes.This method inspects the application-wide focus widget. If it is a descendant of this panel’s tab widget it is explicitly cleared of focus, which causes Qt to emit the
editingFinishedsignal on any focusedQLineEditand flush the edit to the plugin before the action proceeds.Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = ConfigPanel(plugin_manager=pm) >>> panel.commit_pending_changes() # no-op when nothing is focused
- property expand_button: QToolButton¶
Button that restores the configuration panel.
- set_collapsed(collapsed: bool) None[source]¶
Switch between the full configuration pages and compact tab strip.
- show_placeholder() None[source]¶
Display a centred ‘no step selected’ message in the panel.
Convenience wrapper around
show_plugin(None)that also adds a single informational tab so the panel does not appear completely empty.Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> pm = PluginManager() >>> panel = ConfigPanel(plugin_manager=pm) >>> panel.show_placeholder() >>> panel.tabs.count() 1
- show_plugin(plugin: BasePlugin | None) None[source]¶
Display the configuration tabs for plugin, replacing any currently shown tabs.
Tab widgets are sourced from
config_tabs(). BecauseTracePlugincaches its tab widgets, user-edited state is preserved when a plugin is deselected and re-selected in the sequence editor.Passing
Noneremoves all tabs and shows an empty panel.- Parameters:
plugin (BasePlugin | None) – The plugin whose tabs should be displayed, or
Noneto clear the panel.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.core.plugin_manager import PluginManager >>> from stoner_measurement.plugins.trace import DummyPlugin >>> pm = PluginManager() >>> panel = ConfigPanel(plugin_manager=pm) >>> plugin = DummyPlugin() >>> panel.show_plugin(plugin) >>> panel.tabs.count() 3 >>> panel.show_plugin(None) >>> panel.tabs.count() 0
- property tabs: QTabWidget¶
The underlying
QTabWidget.
Non-modal control panel for the legacy X-ray diffractometer.
- class stoner_measurement.ui.xray_panel.XrayControlPanel(parent: QWidget | None = None)[source]¶
Bases:
QWidgetConnect, move and count with the X-ray diffractometer engine.
- class stoner_measurement.ui.xray_panel.XrayGeometryWidget(parent: QWidget | None = None)[source]¶
Bases:
QWidgetLive vector synoptic of source, sample, detector and diffraction rays.
Reusable round dial widget for displaying angular or scalar values.
Provides RoundDialWidget, a scalable Qt widget that renders a
LabVIEW-style circular dial face with configurable value range, angular span,
tick marks, labels, pointer styling, and automatic app-theme integration.
The dial uses a top-referenced angular convention:
0degrees points vertically upwards.Positive angles advance clockwise.
90degrees points to the right.180degrees points downwards.270degrees points to the left.
This convention matches common instrument-panel displays for position and direction readback.
The widget is display-only by design and does not implement any interactive knob or drag behaviour.
- class stoner_measurement.ui.widgets.round_dial.RoundDialWidget(parent: QWidget | None = None)[source]¶
Bases:
QWidgetScalable circular dial widget for angular and scalar readback.
The widget maps a numeric value from a configurable range onto a circular scale whose minimum and maximum may be placed at arbitrary dial angles. The scale can cover a partial arc or a complete revolution. Labels and tick marks are generated automatically and the control scales with the widget size.
Angles are specified in dial coordinates where
0is vertically at the top and increases clockwise.- Signals:
- valueChanged (float):
Emitted whenever
setValue()changes the stored value.
- Parameters:
parent – Optional parent widget.
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> d = RoundDialWidget() >>> d.minimumValue() 0.0 >>> d.maximumValue() 360.0 >>> d.setRange(-180, 180) >>> d.setScaleAngles(-135, 135) >>> d.setValue(45) >>> round(d.value(), 1) 45.0
- bottomReservedFraction() float[source]¶
Return the fraction of widget height reserved below the dial face.
- scaleBandStops() list[tuple[float, QColor]][source]¶
Return the configured coloured scale-band stops.
- setBottomReservedFraction(fraction: float) None[source]¶
Set the fraction of widget height reserved below the dial face.
- setCompassLabelMode(points: int = 8) None[source]¶
Set compass labels with 4, 8, or 16 named directions.
- setCustomLabels(labels: dict[float, str] | None) None[source]¶
Set explicit value-to-label text mappings.
- setDecimals(decimals: int) None[source]¶
Set the number of decimal places used in labels and value text.
- setLabelBackgroundColor(color: QColor | str) None[source]¶
Set the background colour used behind labels.
- setLabelBackgroundVisible(visible: bool) None[source]¶
Show or hide a background patch behind label text.
- setLabelFontScale(scale: float) None[source]¶
Set label font size as a fraction of widget side length.
- setLabelRadiusFactor(factor: float) None[source]¶
Set label placement radius as a fraction of dial radius.
- setMinorTicksPerMajor(count: int) None[source]¶
Set the number of minor subdivisions between major ticks.
- setPreferredLabelCounts(counts: list[int] | None) None[source]¶
Set preferred evenly spaced label counts to try before drawing.
- setPreserveEndpointLabels(preserve: bool) None[source]¶
Set whether scale endpoint labels should be preferred when possible.
- setRange(minimum: float, maximum: float) None[source]¶
Set the numeric range displayed by the dial.
- Parameters:
minimum – Value corresponding to
minimumAngle().maximum – Value corresponding to
maximumAngle().
- Raises:
ValueError – If
maximumis not greater thanminimum.
- setScaleAngles(minimum_angle: float, maximum_angle: float) None[source]¶
Set dial angles for the numeric range endpoints.
Angles are expressed in top-referenced clockwise degrees. The values are not wrapped internally, so a full-scale clockwise sweep from top back to top should be expressed as
0to360.- Parameters:
minimum_angle – Dial angle of the minimum value.
maximum_angle – Dial angle of the maximum value.
- Raises:
ValueError – If both angles are equal.
- setScaleBandStops(stops: list[tuple[float, QColor | str]]) None[source]¶
Set interpolated coloured scale-band stops as (value, colour).
- setScaleBandVisible(visible: bool) None[source]¶
Show or hide the coloured band behind the scale labels.
- setScaleBandWidthFactor(factor: float) None[source]¶
Set the coloured scale-band width as a fraction of dial radius.
- setTickSteps(major: float, minor_count: int, label_step: float | None = None) None[source]¶
Set major/minor tick and label spacing in one call.
- setTitleVerticalOffsetFraction(fraction: float) None[source]¶
Set a small title offset relative to the dial bounding box height.
- setTopReservedFraction(fraction: float) None[source]¶
Set the fraction of widget height reserved above the dial face.
- setValue(value: float) None[source]¶
Set the displayed value.
The value is clamped to the configured numeric range. If wrap mode is enabled, the value is first wrapped into the configured numeric interval before display.
- Parameters:
value – New value to display.
- setValueFontScale(scale: float) None[source]¶
Set value text font size as a fraction of dial radius.
- topReservedFraction() float[source]¶
Return the fraction of widget height reserved above the dial face.
- valueChanged¶
Qt signal.
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.
Demonstration widgets for stoner_measurement.ui.widgets.RoundDialWidget.
- class stoner_measurement.ui.widgets.round_dial_demo.RoundDialDemoWidget(parent: QWidget | None = None)[source]¶
Bases:
QWidgetSmall reusable demo panel showcasing common dial configurations.
- property dial: RoundDialWidget¶
Return the live dial widget used by the demo.
Simple reusable panel embedding one or more round dial displays.
This module provides a lightweight container suitable for dropping into other application panels when a dial-style readback is desired.
- class stoner_measurement.ui.widgets.round_dial_panel.RoundDialPanel(parent: QWidget | None = None)[source]¶
Bases:
QWidgetConvenience container for one or more
RoundDialWidgetinstances.- add_dial(title: str, row: int = 0, column: int = 0, *, minimum: float = 0.0, maximum: float = 360.0, minimum_angle: float = 0.0, maximum_angle: float = 360.0, major_tick_step: float = 30.0, minor_ticks_per_major: int = 4, label_step: float = 30.0, units: str = '') RoundDialWidget[source]¶
Create, configure, add, and return a dial widget.
- dials() list[RoundDialWidget][source]¶
Return the dials currently contained in the panel.