From 767fa5f6fb7df4b832f551de7ccb1ac408c4bceb Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 9 Apr 2023 17:21:40 +0200 Subject: [PATCH] timer needs to be child of window --- src/gui_qt/main/mainwindow.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index b02d79e..10420ca 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -80,6 +80,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self.__timer.start(3*60*1000) # every three minutese self.__timer.timeout.connect(self._autosave) + self.fit_timer = QtCore.QTimer() + self.fit_timer.setInterval(500) + self.fit_timer.timeout.connect( + lambda: self.status.setText(f'Fit running... ({self.management.fitter.step} evaluations)')) + def _init_gui(self): self.setupUi(self) make_action_icons(self) @@ -887,10 +892,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self.fit_dialog.fit_button.setEnabled(False) self.management.start_fit(parameter, links, fit_options) self.status.setText('Fit running...'.format(self.management.fitter.step)) - tim = QtCore.QTimer() - tim.setInterval(500) - tim.timeout.connect(lambda: self.status.setText(f'Fit running... ({self.management.fitter.step} evaluations)')) - tim.start(500) + self.fit_timer.start(500) @QtCore.pyqtSlot(dict, int, bool) def show_fit_preview(self, funcs: dict, num: int, show: bool): @@ -914,6 +916,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @QtCore.pyqtSlot(list) def show_fit_results(self, results: list): self.fit_dialog.fit_button.setEnabled(True) + self.fit_timer.stop() self.status.setText('') if results: res_dialog = QFitResult(results, self.management, parent=self)