From 5c081b054772eaa8b6070e7035a7fddb3ac15b18 Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 20 Jul 2023 15:54:28 +0800 Subject: [PATCH] Add samples box in menu --- pytec/tec_qt.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 05913bc..16f6b7d 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -203,6 +203,24 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.menu.addAction(clear) self.menu.clear = clear + self.samples_spinbox = QtWidgets.QSpinBox() + self.samples_spinbox.setRange(2, 100000) + self.samples_spinbox.setSuffix(' samples') + self.samples_spinbox.setValue(self.max_samples) + self.samples_spinbox.valueChanged.connect(self.set_max_samples) + + limit_samples = QtWidgets.QWidgetAction(self.menu) + limit_samples.setDefaultWidget(self.samples_spinbox) + self.menu.addAction(limit_samples) + self.menu.limit_samples = limit_samples + + @pyqtSlot(int) + def set_max_samples(self, samples: int): + self.ch0_t_connector.max_points = samples + self.ch0_i_connector.max_points = samples + self.ch1_t_connector.max_points = samples + self.ch1_i_connector.max_points = samples + def _set_up_graphs(self): for graph in self.ch0_t_graph, self.ch0_i_graph, self.ch1_t_graph, self.ch1_i_graph: time_axis = LiveAxis('bottom', text="Time since Thermostat reset", **{Axis.TICK_FORMAT: Axis.DURATION})