View¶
Base classes¶
Base view class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Identity key of the view. Passed as positional-only argument. |
required |
kwargs
|
Any
|
Additional keyword arguments for view subclasses. |
{}
|
Source code in src/redsun/view/_base.py
view_position
abstractmethod
property
¶
Position of the view component in the main view of the UI.
Bases: Protocol
Minimal protocol a view component should implement.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Identity key of the view. |
Notes
Access to the virtual container is optional and should be acquired
by implementing :class:~redsun.virtual.IsInjectable.
Source code in src/redsun/view/_base.py
view_position
abstractmethod
property
¶
Position of the view component in the main view of the UI.
Supported view positions.
Used to define the position of a view component in the main view of the UI.
Warning
These values are based on how Qt manages dock widgets. They may change in the future.
Attributes:
| Name | Type | Description |
|---|---|---|
CENTER |
str
|
Center view position. |
LEFT |
str
|
Left view position. |
RIGHT |
str
|
Right view position. |
TOP |
str
|
Top view position. |
BOTTOM |
str
|
Bottom view position. |
Source code in src/redsun/view/__init__.py
Qt widgets¶
Qt widget utilities for plan-based UIs.
This module provides the building blocks for a plan parameter form:
ActionButton— aQPushButtonthat carriesActionmetadata and auto-updates its label when toggled.PlanWidget— a frozen dataclass owning all Qt widgets for a single plan (parameter form, run/pause buttons, action buttons).create_plan_widget— factory that builds a completePlanWidgetfrom aPlanSpecand wires up the caller-supplied callbacks.PlanInfoDialog— a simple Markdown-rendering dialog for displaying the plan docstring (if available).create_param_widget— re-exported from_widget_factoryfor convenience.
ActionButton
¶
Bases: QPushButton
A QPushButton that carries Action metadata.
Automatically updates its label based on toggle state using the action's
toggle_states attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action
|
The action to associate with this button. |
required |
parent
|
QWidget | None
|
The parent widget. Default is |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
action |
Action
|
The action associated with this button. |
Source code in src/redsun/view/qt/utils.py
PlanInfoDialog
¶
Bases: QDialog
Dialog to provide information to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title of the dialog window. |
required |
text
|
str
|
The text to display in the text edit area (rendered as Markdown). |
required |
parent
|
QWidget | None
|
The parent widget, by default |
None
|
Source code in src/redsun/view/qt/utils.py
show_dialog
classmethod
¶
Create and show the dialog in one step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title of the dialog window. |
required |
text
|
str
|
The text to display in the text edit area. |
required |
parent
|
QWidget | None
|
The parent widget, by default |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Dialog result code ( |
Source code in src/redsun/view/qt/utils.py
create_plan_widget
¶
create_plan_widget(
spec: PlanSpec,
run_callback: Callable[[], None] | None = None,
toggle_callback: Callable[[bool], None] | None = None,
pause_callback: Callable[[bool], None] | None = None,
action_clicked_callback: Callable[[str], None]
| None = None,
action_toggled_callback: Callable[[bool, str], None]
| None = None,
) -> PlanWidget
Build a complete PlanWidget for spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PlanSpec
|
The plan specification to build a widget for. |
required |
run_callback
|
Callable[[], None] | None
|
Connected to |
None
|
toggle_callback
|
Callable[[bool], None] | None
|
Connected to |
None
|
pause_callback
|
Callable[[bool], None] | None
|
Connected to |
None
|
action_clicked_callback
|
Callable[[str], None] | None
|
Called with |
None
|
action_toggled_callback
|
Callable[[bool, str], None] | None
|
Called with |
None
|
Returns:
| Type | Description |
|---|---|
PlanWidget
|
Fully constructed widget, ready to be added to a |
Source code in src/redsun/view/qt/utils.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
Container for all Qt widgets that represent a single plan.
Source code in src/redsun/view/qt/utils.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
group_box
instance-attribute
¶
The top-level page widget suitable for stacking in a QStackedWidget.
container
instance-attribute
¶
The magicgui Container holding the parameter input widgets.
device_widgets
instance-attribute
¶
Device parameter widgets (DeviceSequenceEdit or ComboBox).
Exposed so callers can connect validation logic directly to each
device widget's changed signal.
params_widget
instance-attribute
¶
Widget wrapping devices_group + params_group; disable this to lock all parameter inputs without affecting the run/stop/pause buttons.
action_buttons
instance-attribute
¶
Mapping of action names to their buttons for direct access.
actions_group
class-attribute
instance-attribute
¶
The group box containing action buttons, or None if the plan has no actions.
pause_button
class-attribute
instance-attribute
¶
The pause/resume button, or None if the plan is not pausable.
parameters
property
¶
Current parameter values keyed by parameter name.
The presenter is responsible for routing these into positional args
and keyword args via collect_arguments / resolve_arguments.
toggle
¶
Update UI state when a togglable plan starts or stops.
Source code in src/redsun/view/qt/utils.py
pause
¶
Update UI state when a plan is paused or resumed.
Source code in src/redsun/view/qt/utils.py
setEnabled
¶
Enable or disable the entire plan widget.
Source code in src/redsun/view/qt/utils.py
enable_actions
¶
Enable or disable the actions group box.
Source code in src/redsun/view/qt/utils.py
get_action_button
¶
Return the ActionButton for action_name, or None if absent.
Source code in src/redsun/view/qt/utils.py
Widget factory for plan parameter forms.
Maps a ParamDescription to an appropriate magicgui widget via a
table-driven factory registry (_WIDGET_FACTORY_MAP).
create_param_widget is the public entry point. It walks
_WIDGET_FACTORY_MAP — an ordered list of (predicate, factory)
pairs — and calls the first factory whose predicate matches the given
ParamDescription.
Extending the system
To add support for a new annotation shape, define a predicate and a
factory function and insert a (predicate, factory) tuple at the
right priority position in _WIDGET_FACTORY_MAP. Nothing else needs
to change.
Unresolvable annotations
create_plan_spec pre-validates that every required parameter can be
mapped to a widget. Plans with unresolvable required parameters raise
UnresolvableAnnotationError and are skipped by the presenter.
create_param_widget therefore raises RuntimeError (not a silent
fallback) if all factory entries fail.
create_param_widget
¶
Create a magicgui widget for param via the factory registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
ParamDescription
|
The parameter specification. |
required |
Returns:
| Type | Description |
|---|---|
Widget
|
The created widget. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If every entry in |
Source code in src/redsun/view/qt/_widget_factory.py
Descriptor-driven tree view for displaying and editing device settings.
DescriptorTreeView is a self-contained QTreeWidget-based widget that
renders Bluesky-compatible describe_configuration / read_configuration
dicts as a two-column property tree.
The design is inspired by the ParameterTree widget from the
pyqtgraph library (MIT licence,
© 2012 University of North Carolina at Chapel Hill, Luke Campagnola).
Layout (two columns: Setting | Value):
The source field of a Bluesky Descriptor is used as the group label.
When it carries the :readonly suffix (e.g. "settings:readonly") the
value cell is rendered as a greyed QLabel and cannot be edited.
The device-name root level is omitted — present one DescriptorTreeView
per device, e.g. inside a QTabWidget.
DescriptorTreeView
¶
Bases: QTreeWidget
Two-column property tree for browsing and editing device settings.
Modelled after the pyqtgraph ParameterTree: uses setItemWidget
to place editor/display widgets permanently in the Value column, so
there are no popup editors and no delegate geometry issues.
The device-name root level is omitted — use one widget per device,
e.g. inside a QTabWidget.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptors
|
dict[str, Descriptor]
|
Flat |
required |
readings
|
dict[str, Reading[Any]]
|
Flat |
required |
parent
|
QWidget | None
|
Optional parent widget. |
None
|
Signals
sigPropertyChanged: Signal[str, Any]
Emitted when the user commits an edit.
Carries (key: str, value: Any).
Source code in src/redsun/view/qt/treeview.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
update_reading
¶
Push a live value update for key into the corresponding widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Canonical |
required |
reading
|
Reading[Any]
|
New reading dict; only |
required |
Source code in src/redsun/view/qt/treeview.py
confirm_change
¶
Confirm or revert a pending user edit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Canonical key of the setting that was attempted. |
required |
success
|
bool
|
|
required |