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 11949f9..aa1b4d8 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -124,11 +124,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() @@ -141,9 +137,6 @@ class MainWindow(QtWidgets.QMainWindow): self.loading_spinner.hide() - def clear_graphs(self): - self.channel_graphs.clear_graphs() - @asyncSlot(ThermostatConnectionState) async def _on_connection_changed(self, result): match result: @@ -177,7 +170,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: @@ -317,9 +310,9 @@ async def coro_main(): if args.connect: if args.HOST: - main_window.host_set_line.setText(args.HOST) + main_window.conn_menu.host_set_line.setText(args.HOST) if args.PORT: - main_window.port_set_spin.setValue(int(args.PORT)) + main_window.conn_menu.port_set_spin.setValue(int(args.PORT)) main_window.connect_btn.click() await app_quit_event.wait()