Skip to content

script_view

frog.gui.measure_script.script_view ¤

Contains a panel for loading and editing measure scripts.

Attributes¤

Classes¤

ScriptControl() ¤

Bases: QGroupBox

A panel for loading and editing measure scripts.

Create a new ScriptControl.

Source code in frog/gui/measure_script/script_view.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
def __init__(self) -> None:
    """Create a new ScriptControl."""
    super().__init__("Script control")

    create_btn = QPushButton("Create new script")
    create_btn.clicked.connect(self._create_btn_clicked)

    edit_btn = QPushButton("Edit script")
    edit_btn.clicked.connect(self._edit_btn_clicked)

    self.script_path = OpenFileWidget(
        initial_file_path=_get_previous_script_path(),
        extension="yaml",
        parent=self,
        caption="Choose measure script to load",
        dir=str(DEFAULT_SCRIPT_PATH),
    )

    run_btn = QPushButton("Run script")
    run_btn.clicked.connect(self._run_btn_clicked)
    run_btn.setEnabled(False)

    self._enable_counter = EventCounter(
        lambda: run_btn.setEnabled(True),
        lambda: run_btn.setEnabled(False),
        target_count=2,
        device_names=(STEPPER_MOTOR_TOPIC,),
    )
    """A counter to enable/disable the "Run" button."""

    layout = QGridLayout()
    layout.addWidget(create_btn, 0, 0)
    layout.addWidget(edit_btn, 0, 1)
    layout.addWidget(self.script_path, 1, 0)
    layout.addWidget(run_btn, 1, 1)
    self.setLayout(layout)

    # Enable the run button when the spectrometer is connected and not already
    # measuring and disable otherwise
    self._spectrometer_ready = False
    pub.subscribe(
        self._on_spectrometer_status_changed,
        f"device.{SPECTROMETER_TOPIC}.status",
    )
    pub.subscribe(
        self._on_spectrometer_disconnect, f"device.closed.{SPECTROMETER_TOPIC}"
    )

    # Show/hide self.run_dialog on measure script begin/end
    pub.subscribe(self._show_run_dialog, "measure_script.begin")
    pub.subscribe(self._hide_run_dialog, "measure_script.end")

    # Keep track of whether recording is taking place, so we can remind user to
    # start recording
    pub.subscribe(self._on_recording_start, "data_file.opened")
    pub.subscribe(self._on_recording_stop, "data_file.close")
    self._data_file_recording = False
    """Whether data file is currently being recorded."""

    self.edit_dialog: ScriptEditDialog
    """A dialog for editing the contents of a measure script."""

    self.run_dialog: ScriptRunDialog
    """A dialog showing the progress of a running measure script."""
Attributes¤
edit_dialog instance-attribute ¤

A dialog for editing the contents of a measure script.

run_dialog instance-attribute ¤

A dialog showing the progress of a running measure script.

Functions¤