From 9756bf958b092dca320d2250627df6805ce3a985 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 5 Jul 2023 18:11:58 +0200 Subject: [PATCH] close #86; --- src/gui_qt/fit/result.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gui_qt/fit/result.py b/src/gui_qt/fit/result.py index d854ce4..6a820ed 100644 --- a/src/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -64,8 +64,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.cmap = RdBuCMap(vmin=-1, vmax=1) - self.buttonBox.accepted.connect(self.accept) - self.graph_checkBox.stateChanged.connect(lambda x: self.graph_comboBox.setEnabled(x == QtCore.Qt.Unchecked)) self.logy_box.stateChanged.connect(lambda x: self.fit_plot.setLogMode(y=bool(x))) @@ -315,22 +313,27 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): parts = self.partial_checkBox.checkState() == QtCore.Qt.Checked extrapolate = [None, None, None] + error = [] if self.extrapolate_box.isChecked(): try: extrapolate[0] = float(self.minx_line.text()) - except TypeError: - pass + except (TypeError, ValueError): + error.append('Start value is missing') try: extrapolate[1] = float(self.maxx_line.text()) - except TypeError: - pass + except (TypeError, ValueError): + error.append('End value is missing') try: extrapolate[2] = int(self.numx_line.text()) - except TypeError: - pass + except (TypeError, ValueError): + error.append('Number of points is missing') - self.closed.emit(self._results, self._opts, graph, plot_fits, parts, extrapolate) - self.accept() + if error: + msg = QtWidgets.QMessageBox.warning(self, 'Error', 'Extrapolation failed because:\n' + '\n'.join(error)) + return + else: + self.closed.emit(self._results, self._opts, graph, plot_fits, parts, extrapolate) + self.accept() else: self.reject()