timer needs to be child of window

This commit is contained in:
Dominik Demuth 2023-04-09 17:21:40 +02:00
parent 02f8a3bb31
commit 767fa5f6fb

View File

@ -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)