Skip to content

Commit a30b288

Browse files
committed
update chirp tab checkboxes to use CLParamCheckBox
1 parent 551812a commit a30b288

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/CLGui/ChirpTab.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import CLProject as clp
2-
from CLGui import CLTab, CLParameter, CLParamNum, CLParamDropdown, CLParamFile, QCollapsible, QHSeparator, CalibrationDialog, undo_stack
2+
from CLGui import CLTab, CLParameter, CLParamNum, CLParamDropdown, CLParamFile, CLParamCheckBox, QCollapsible, QHSeparator, CalibrationDialog, undo_stack
33
from CLAnalysis import generate_stimulus, read_audio_file, read_response, generate_output_stimulus, generate_stimulus_file, audio_file_info, write_audio_file
44
import numpy as np
5-
from qtpy.QtWidgets import QPushButton, QCheckBox, QAbstractSpinBox, QFileDialog, QComboBox, QFrame, QVBoxLayout
5+
from qtpy.QtWidgets import QPushButton, QAbstractSpinBox, QFileDialog, QComboBox, QFrame, QVBoxLayout
66
from qtpy.QtCore import Signal, Slot, QObject
77
import pyqtgraph as pg
88
from engineering_notation import EngNumber
@@ -375,13 +375,18 @@ def update_post_sweep_units(index):
375375
self.post_sweep.units_update_callback = update_post_sweep_units
376376

377377
# include leading silence checkbox
378-
self.include_silence = QCheckBox('Include leading silence')
378+
self.include_silence = CLParamCheckBox('Include leading silence')
379379
self.include_silence.setChecked(clp.project['output']['include_silence'])
380380
layout.addWidget(self.include_silence)
381381
def update_include_silence(checked):
382382
clp.project['output']['include_silence'] = bool(checked)
383+
undo_stack.push(undo_include_silence, not checked, undo_include_silence, checked)
383384
update_output_length()
384-
self.include_silence.stateChanged.connect(update_include_silence)
385+
self.include_silence.update_callback = update_include_silence
386+
def undo_include_silence(checked):
387+
undo_stack.paused = True
388+
self.include_silence.setChecked(checked)
389+
undo_stack.paused = False
385390

386391
# total length text box (non-interactive) - s/sample dropdown
387392
def calc_output_length(unit='samples'):
@@ -540,7 +545,9 @@ def __init__(self, chirp_tab):
540545
layout.addWidget(self.refresh)
541546
def refresh_devices():
542547
DeviceIO.restart_pyaudio()
548+
undo_stack.paused = True
543549
update_api(self.api.dropdown.currentIndex())
550+
undo_stack.paused = False
544551
# todo: also refresh input devices
545552
self.refresh.clicked.connect(refresh_devices)
546553

@@ -662,15 +669,15 @@ def update_post_sweep_units(index):
662669
self.post_sweep.units_update_callback = update_post_sweep_units
663670

664671
# include leading silence checkbox
665-
self.include_silence = QCheckBox('Include leading silence')
672+
self.include_silence = CLParamCheckBox('Include leading silence')
666673
self.include_silence.setChecked(clp.project['output']['include_silence'])
667674
layout.addWidget(self.include_silence)
668675
def update_include_silence(checked):
669676
clp.project['output']['include_silence'] = bool(checked)
670677
update_output_length()
671678
if clp.project['input']['mode'] == 'device' and clp.project['input']['use_output_length']:
672679
chirp_tab.input_params.device_input.update_auto_length(True)
673-
self.include_silence.stateChanged.connect(update_include_silence)
680+
self.include_silence.update_callback = update_include_silence
674681

675682
# total length text box (non-interactive) - s/sample dropdown
676683
def calc_output_length(unit='samples'):
@@ -1024,7 +1031,9 @@ def __init__(self, chirp_tab):
10241031
layout.addWidget(self.refresh)
10251032
def refresh_devices():
10261033
DeviceIO.restart_pyaudio()
1034+
undo_stack.paused = True
10271035
update_api(self.api.dropdown.currentIndex())
1036+
undo_stack.paused = False
10281037
# todo: also refresh output devices
10291038
self.refresh.clicked.connect(refresh_devices)
10301039

@@ -1087,15 +1096,15 @@ def update_device(index):
10871096
self.device.update_callback = update_device
10881097

10891098
# auto capture length checkbox
1090-
self.auto_length = QCheckBox('auto')
1099+
self.auto_length = CLParamCheckBox('auto')
10911100
self.auto_length.setChecked(clp.project['input']['use_output_length'])
10921101
def update_auto_length(checked):
10931102
clp.project['input']['use_output_length'] = checked
10941103
self.capture_length.spin_box.setEnabled(not checked)
10951104
if checked:
10961105
clp.project['input']['capture_length'] = calc_output_length('seconds')
10971106
update_capture_length_units(self.capture_length.units.currentIndex())
1098-
self.auto_length.stateChanged.connect(update_auto_length)
1107+
self.auto_length.update_callback = update_auto_length
10991108
def calc_output_length(unit='samples'):
11001109
sig_length = round(clp.project['output']['pre_sweep']*clp.project['output']['sample_rate'])
11011110
sig_length += round(clp.project['chirp_length']*clp.project['output']['sample_rate'])

0 commit comments

Comments
 (0)