control.gui_dict:var

Variable storage for implementing with qt GUI.

Usage

Source

control.gui_dict:var(
    *args,
    **kwargs,
)

One var is one row of a control panel: it stores the current value, the Qt widgets that display and edit it (see widgets), and the metadata of the row.

Emits valueChanged signal if the value has changed so it can be connected to a display.

Parameters

dtype: type or None

Type of the value (float, int, str, …). Also the first positional argument.

columns: list[guiObject] or guiObject

Widget type(s) of the row, typically two entries: readout and setpoint. A plain str is shown as a static label.

unit: str

Unit string, shown in the label and written to the log file.

log: bool

Log the value by default, i.e. after start-up. Requires dtype to be set.

init: object or list

Initial content of the column(s): values, spin box ranges, combo box entries or button texts. A single object is applied to both columns.

hide: bool

Hide the row unless the “extended” view is enabled.

modify: MethodBundle or list
MethodBundle(s) applied to the column widget(s) for custom setup and value change handling.

Notes

Setting value updates the readout widget and triggers any change handlers. Use getGUIvalue() to read the value as entered in the setpoint widget.

Attributes

Name Description
tooltip Get the tooltip of the variable.
unit Get the unit of the variable.
value Get the current value of the variable.
widgets Get the Qt widgets of the variable row.

tooltip

Get the tooltip of the variable.

tooltip: str


unit

Get the unit of the variable.

unit: str


value

Get the current value of the variable.

value: Any


widgets

Get the Qt widgets of the variable row.

widgets: list[Any]

Methods

Name Description
__init__() Initialize the variable storage.
copy_value() Copy the read values into the set field.
getGUIvalue() Return the value of the GUI element in the respective column.
setValue() Set the value of the variable.

__init__()

Initialize the variable storage.

Usage

Source

__init__(
    self,
    dtype: type | None,
    columns: list[guiObject | str | None] | str | guiObject | None = None,
    unit: str = '',
    log: bool | None = False,
    init: object | None = None,
    hide: bool = False,
    modify: MethodBundle | list[MethodBundle | None] | None = None,
) -> None
__init__(
    self,
    __dtype: type | None,
) -> None

copy_value()

Copy the read values into the set field.

Usage

Source

copy_value()

Thread-safe: emits copyValueRequested, which Qt dispatches to the GUI thread via a queued connection when called from a worker thread, and as a direct call when already on the GUI thread.


getGUIvalue()

Return the value of the GUI element in the respective column.

Usage

Source

getGUIvalue(column=2)

On the widget-owning thread the widget is read directly. Otherwise a cached GUI value is returned when available.

Parameters

column: int = 2
Column index in the widget list to read the value from.

Returns

Any
The value from the GUI element, cast to variableType.

Raises

RuntimeError
If the method is called off the widget-owning thread and no thread-safe value source is available.

setValue()

Set the value of the variable.

Usage

Source

setValue(newValue)

Parameters

newValue: Any
The new value to set.