From f141705b0e09e008905602623cc8283a1dfd61e8 Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 27 Aug 2024 15:40:59 +0800 Subject: [PATCH] Move plot_options_menu stuff into menu --- pytec/pytec/gui/view/plot_options_menu.py | 6 +++++- pytec/tec_qt.py | 11 ++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pytec/pytec/gui/view/plot_options_menu.py b/pytec/pytec/gui/view/plot_options_menu.py index 7817d58..8ec6f76 100644 --- a/pytec/pytec/gui/view/plot_options_menu.py +++ b/pytec/pytec/gui/view/plot_options_menu.py @@ -2,18 +2,22 @@ from PyQt6 import QtWidgets, QtGui class PlotOptionsMenu(QtWidgets.QMenu): - def __init__(self, max_samples=1000): + def __init__(self, channel_graphs, max_samples=1000): super().__init__() + self.channel_graphs = channel_graphs + self.setTitle("Plot Settings") clear = QtGui.QAction("Clear graphs", self) self.addAction(clear) self.clear = clear + self.clear.triggered.connect(self.channel_graphs.clear_graphs) self.samples_spinbox = QtWidgets.QSpinBox() self.samples_spinbox.setRange(2, 100000) self.samples_spinbox.setSuffix(" samples") self.samples_spinbox.setValue(max_samples) + self.samples_spinbox.valueChanged.connect(self.channel_graphs.set_max_samples) limit_samples = QtWidgets.QWidgetAction(self) limit_samples.setDefaultWidget(self.samples_spinbox) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index ad9486c..7d8c679 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -126,11 +126,7 @@ class MainWindow(QtWidgets.QMainWindow): self.thermostat.report_update.connect(self.channel_graphs.update_report) self.thermostat.pid_update.connect(self.channel_graphs.update_pid) - self.plot_options_menu = PlotOptionsMenu() - self.plot_options_menu.clear.triggered.connect(self.clear_graphs) - self.plot_options_menu.samples_spinbox.valueChanged.connect( - self.channel_graphs.set_max_samples - ) + self.plot_options_menu = PlotOptionsMenu(self.channel_graphs) self.plot_settings.setMenu(self.plot_options_menu) self.conn_menu = ConnMenu() @@ -150,9 +146,6 @@ class MainWindow(QtWidgets.QMainWindow): self.port_set_spin.setValue(int(args.PORT)) self.connect_btn.click() - def clear_graphs(self): - self.channel_graphs.clear_graphs() - @asyncSlot(ThermostatConnectionState) async def _on_connection_changed(self, result): match result: @@ -186,7 +179,7 @@ class MainWindow(QtWidgets.QMainWindow): self.loading_spinner.stop() self.thermostat_ctrl_menu.fan_pwm_warning.setPixmap(QtGui.QPixmap()) self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("") - self.clear_graphs() + self.channel_graphs.clear_graphs() self.report_box.setChecked(False) for ch in range(self.NUM_CHANNELS): if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF: