View¶
Base classes¶
Bases: ABC
Base view class.
Does not inherit PView, whose read-only name
property would shadow the instance attribute set here. Instances satisfy
the protocol by shape, like any other view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Identity key of the view, positional-only. |
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 in the main window.
Bases: Protocol
Protocol of a view component.
name is a read-only property, so an instance attribute, a class
attribute or a property satisfies it.
Notes
A view reaches the virtual container by implementing
IsInjectable.
Checked with isinstance on the built instance, since attributes
assigned in __init__ do not exist on the class.
Source code in src/redsun/view/_base.py
Where a view sits in the main window.
Warning
The values follow Qt's dock widget areas and may change.
Source code in src/redsun/view/__init__.py
Qt widgets¶
Qt widgets for interfaces that run plans.
ActionButton: aQPushButtoncarrying anAction, its label following the toggle state.PlanWidget: a frozen dataclass owning one plan's widgets (parameter form, run and pause buttons, action buttons).create_plan_widget: builds aPlanWidgetfrom aPlanSpecand connects the given callbacks.PlanInfoDialog: a dialog rendering a plan's docstring as Markdown.create_param_widget: re-exported from_widget_factory.
ActionButton
¶
Bases: QPushButton
A QPushButton carrying an Action.
Its label follows the toggle state, using the action's toggle_states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action
|
The button's action. |
required |
parent
|
QWidget | None
|
The parent widget. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
action |
Action
|
The button's action. |
Source code in src/redsun/view/qt/utils.py
PlanInfoDialog
¶
Bases: QDialog
Dialog showing information to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title of the dialog window. |
required |
text
|
str
|
Text shown, rendered as Markdown. |
required |
parent
|
QWidget | None
|
The parent widget. |
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
|
Text shown. |
required |
parent
|
QWidget | None
|
The parent widget. |
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's specification. |
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
|
The widget, ready for a |
Source code in src/redsun/view/qt/utils.py
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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
The Qt widgets of one plan.
Source code in src/redsun/view/qt/utils.py
80 81 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 | |
container
instance-attribute
¶
The magicgui Container of parameter widgets.
device_widgets
instance-attribute
¶
Device parameter widgets (DeviceSequenceEdit or ComboBox).
Exposed so callers can connect validation to each widget's changed
signal.
params_widget
instance-attribute
¶
Widget holding devices_group and params_group; disabling it locks every parameter input but not the run, stop and pause buttons.
action_buttons
instance-attribute
¶
Action buttons by action name.
actions_group
class-attribute
instance-attribute
¶
The group box of 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 by name.
The presenter turns them into positional and keyword arguments with
collect_arguments / resolve_arguments.
toggle
¶
Update the widgets when a togglable plan starts or stops.
Source code in src/redsun/view/qt/utils.py
pause
¶
Update the widgets when a plan pauses or resumes.
Source code in src/redsun/view/qt/utils.py
setEnabled
¶
Enable or disable the whole 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
Widgets for plan parameter forms.
create_param_widget maps a ParamDescription to a magicgui widget. It
walks _WIDGET_FACTORY_MAP, an ordered list of (predicate, factory) pairs,
and calls the first factory whose predicate matches.
Extending the system
For a new annotation shape, write a predicate and a factory and insert the pair
at the right priority in _WIDGET_FACTORY_MAP.
Unresolvable annotations
create_plan_spec already checks that every required parameter maps to a
widget: a plan failing that raises UnresolvableAnnotationError and is skipped.
create_param_widget therefore raises RuntimeError if every entry fails,
instead of falling back silently.
create_param_widget
¶
Create a magicgui widget for param.
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
Tree view showing and editing device settings from their descriptors.
DescriptorTreeView, a QTreeWidget, shows bluesky describe() /
read() dicts as a two-column property tree.
The design follows the ParameterTree widget of
pyqtgraph (MIT licence,
© 2012 University of North Carolina at Chapel Hill, Luke Campagnola).
DescriptorTreeView
¶
Bases: QTreeWidget
Two-column property tree for browsing and editing device settings.
Rows are grouped by each descriptor's source field: one header per
device, with the device name dropped from leaf labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptors
|
dict[str, Descriptor]
|
Descriptors by |
required |
readings
|
dict[str, Reading[Any]]
|
Initial readings for the same keys; only |
required |
parent
|
QWidget
|
Parent widget. |
None
|
Signals
sig_property_changed : Signal[str, str, Any] Emitted when the user commits an edit. - str: object name - str: property name - Any: new value
Source code in src/redsun/view/qt/treeview.py
216 217 218 219 220 221 222 223 224 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 | |
update_reading
¶
Show a new reading for key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
|
required |
reading
|
Reading[Any]
|
New reading; 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
|
Key of the edited setting. |
required |
success
|
bool
|
|
required |
Source code in src/redsun/view/qt/treeview.py
Built-ins¶
Bases: QtView
Read-only console of the running session's log records.
Records logged before the view existed are shown too, read from the session buffer. The level selector sets the lowest level shown; since the view redraws from the buffer, lowering the level again brings records back.
Application and service records have their own tabs. The Services tab
appears once a service logs, and its selector narrows it to one service.
Clear log window and Save logs... act on the tab and service shown.
Records are coloured by level, with one palette for light and one for dark backgrounds, chosen from the console's background and redrawn when the palette changes.
New records are drawn in batches, so a burst does not stall the window, and each console keeps no more lines than the buffer holds for it.
With session log files open, Save logs... copies the files of the tab
shown and Open log folder opens their folder in the file browser;
without them the folder button is disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Identity key of the view, positional-only. |
required |
kwargs
|
Any
|
Additional keyword arguments (unused). |
{}
|
Source code in src/redsun/view/qt/_log_view.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 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 | |
colors
property
¶
The level colours in use, chosen from the console's background.
changeEvent
¶
Redraw in the colours of the palette the console now carries.
Source code in src/redsun/view/qt/_log_view.py
closeEvent
¶
Stop following the buffer once the console is closed.
Source code in src/redsun/view/qt/_log_view.py
set_level
¶
Show only records at or above level, redrawing from the buffer.
Source code in src/redsun/view/qt/_log_view.py
clear
¶
Empty the console of the tab shown.
The buffer is untouched, so Save logs... still writes everything and
changing the level brings records back.
Source code in src/redsun/view/qt/_log_view.py
save
¶
Write the records of the tab shown to path, whatever the displayed level.
The Application tab writes application records; the Services tab the selected service's, or every service's in turn. They come from the session's log files if open, so records the buffer dropped are included, and from the buffer otherwise.