QInstrumentRack#
- class QInstrument.QInstrumentRack.QInstrumentRack(parent=None, instruments=None, editable=True, fake=False)[source]#
Bases:
QWidgetA widget that holds multiple instrument widgets in a vertical layout.
The instrument list is persisted to
~/.QInstrument/QInstrumentRack.jsonviaConfigure. On first show, if no instruments were supplied at construction, the saved list is restored. On close, the current list is saved.When
editableisTrue(the default), the rack provides:An “Add instrument…” toolbar button that opens a picker dialog listing all instruments found under
instruments/.A × close button overlaid on each slot to remove that instrument.
A ⋮ drag handle on each slot. Dragging highlights the target slot with a coloured bar and moves the dragged slot to that position on release.
Set
editabletoFalseto hide all of the above, for example when embedding the rack in an application where the instrument set should be fixed.- Parameters:
parent (QWidget | None) – Parent widget. Default:
None.instruments (list[str] | None) – Instrument names to load on construction. Each name is the bare instrument name without the
Qprefix orWidgetsuffix (e.g.'DS345'). Default:None(empty rack).editable (bool) – If
False, the toolbar, drag handles, and close buttons are all hidden. Default:True.fake (bool) – If
True, all instruments — including those added later via the “Add instrument…” dialog — use fake devices instead of probing for real hardware. Default:False.
- property settings: dict#
instrument list as
{'instruments': [...]}.Getting returns instrument names in their current display order, preserving any reordering done by dragging. Setting clears the rack and reloads from the supplied dict.
- Type:
- property editable: bool#
whether the user can add, remove, or reorder instruments.
When
False, the toolbar, drag handles, and close buttons are all hidden. Defaults toTrue.- Type:
- addInstrument(instrument, name='')[source]#
Add an instrument widget instance to the rack.
- Parameters:
instrument (QInstrumentWidget) – The instrument widget to add.
name (str) – Display name. Derived from the widget class name if omitted.
- Return type:
- addInstruments(instruments)[source]#
Add multiple instrument widget instances to the rack.
- Parameters:
instruments (list[QInstrumentWidget]) – Instrument widget instances to add.
- Return type:
- addInstrumentByName(name, fake=False)[source]#
Add an instrument widget by its bare instrument name.
Searches manufacturer subdirectories under
instruments/for a package namednamethat contains awidget.py, then instantiatesQ<name>Widget. Logs a warning and does nothing if the instrument or widget class cannot be found.- Parameters:
name (str) – Bare instrument name without the
Qprefix orWidgetsuffix (e.g.'DS345').fake (bool) – If
True, instantiate the widget with its fake device (from the siblingfake.py) instead of probing for real hardware. The widget will be fully enabled. Falls back to normal instantiation if no fake is available. Default:False.
- Return type:
- addInstrumentsByNames(names, fake=False)[source]#
Add multiple instruments by their bare names.
- Parameters:
names (list[str] | None) – Bare instrument names to load.
Noneis treated as an empty list.fake (bool) – Passed to
addInstrumentByName()for each name. Default:False.
- Return type:
- classmethod availableInstruments()[source]#
Return names of all instruments that have a widget module.
- showEvent(event)[source]#
Restore the instrument list on first show.
On the first show, if no instruments were loaded at construction, calls
Configure.restore()to reload the previously saved instrument list.- Return type: