From 0a99e29d4da0d9f8dcc0f1bfae1989bf0f070bbf Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 4 Nov 2024 13:06:32 +0800 Subject: [PATCH] PyThermostat GUI: Implement PlotSettingsMenu Co-authored-by: linuswck --- .../gui/view/plot_options_menu.py | 25 +++++++++++++++++++ pythermostat/pythermostat/thermostat_qt.py | 4 +++ 2 files changed, 29 insertions(+) create mode 100644 pythermostat/pythermostat/gui/view/plot_options_menu.py diff --git a/pythermostat/pythermostat/gui/view/plot_options_menu.py b/pythermostat/pythermostat/gui/view/plot_options_menu.py new file mode 100644 index 0000000..8ec6f76 --- /dev/null +++ b/pythermostat/pythermostat/gui/view/plot_options_menu.py @@ -0,0 +1,25 @@ +from PyQt6 import QtWidgets, QtGui + + +class PlotOptionsMenu(QtWidgets.QMenu): + 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) + self.addAction(limit_samples) + self.limit_samples = limit_samples diff --git a/pythermostat/pythermostat/thermostat_qt.py b/pythermostat/pythermostat/thermostat_qt.py index a275b27..ac0bbec 100755 --- a/pythermostat/pythermostat/thermostat_qt.py +++ b/pythermostat/pythermostat/thermostat_qt.py @@ -14,6 +14,7 @@ from pythermostat.gui.model.pid_autotuner import PIDAutoTuner from pythermostat.gui.view.connection_details_menu import ConnectionDetailsMenu from pythermostat.gui.view.info_box import InfoBox from pythermostat.gui.view.live_plot_view import LiveDataPlotter +from pythermostat.gui.view.plot_options_menu import PlotOptionsMenu from pythermostat.gui.view.thermostat_settings_menu import ThermostatSettingsMenu from pythermostat.gui.view.zero_limits_warning_view import ZeroLimitsWarningView @@ -99,6 +100,9 @@ class MainWindow(QtWidgets.QMainWindow): ) self.thermostat_settings.setMenu(self._thermostat_settings_menu) + self._plot_options_menu = PlotOptionsMenu(self._channel_graphs) + self.plot_settings.setMenu(self._plot_options_menu) + # Status line self._zero_limits_warning_view = ZeroLimitsWarningView( self._thermostat, self.style(), self.limits_warning