Data models

DictSyncModel/ListSyncModel: maps Python dictionaries/lists onto Qt tables automatically.

Overview

quatm/GUI/widgets/models.py provides the base classes that map Python dictionaries / lists onto Qt table models (derived from ARTIQ’s models). The table interfaces of the experiment queue, preparation station and looper are all built on them.

Core classes

ClassDescription
_SyncSubstructHelper wrapping dictionary operations on the underlying container: triggers the refresh callback after append/insert/pop
DictSyncModelDictionary→table model base class: maps backing_store through the headers/dataNames columns
ListSyncModelList→table model base class (the backing store is a list)
ScheduleModelModel for the experiment queue (ExperimentQueue): tasks sorted by priority and then by task number
PrepModelModel for the preparation station / looper: the backing store is a list whose order can be changed freely

Usage

from quatm.GUI.widgets.models import DictSyncModel

model = DictSyncModel(
    headers=["Name", "Value", "Unit"],
    dataNames=["name", "value", "unit"],
    init={"name": "param1", "value": 100, "unit": "µs"},
)

Concrete business models customise their behaviour by implementing three hooks in a subclass: convert turns a key/value/column into cell content, sort_key returns the sort key, and flags decides per-cell flags such as whether a cell is editable.