From ff2ff01da7d707439a9d1c10423700bbfbfdcb50 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 25 Sep 2024 17:21:46 +0200 Subject: [PATCH] update internal fit infos after function removal --- src/gui_qt/fit/fit_parameter.py | 9 ++++++--- src/gui_qt/fit/fitwindow.py | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gui_qt/fit/fit_parameter.py b/src/gui_qt/fit/fit_parameter.py index e470691..756fb3f 100644 --- a/src/gui_qt/fit/fit_parameter.py +++ b/src/gui_qt/fit/fit_parameter.py @@ -12,12 +12,13 @@ from ..lib.forms import SelectionWidget class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit): value_requested = QtCore.pyqtSignal(int) - def __init__(self, parent=None): + def __init__(self, func_id: int, parent=None): super().__init__(parent=parent) self.setupUi(self) self.func = None self.func_idx = None + self.func_id = func_id self.max_width = QtCore.QSize(0, 0) self.global_parameter = [] self.data_parameter = [] @@ -301,8 +302,10 @@ class ParameterSingleWidget(QtWidgets.QWidget): self.name = name self.parametername.setText(convert(name)) - self.parametername.setToolTip('If this is bold then this parameter is only for this data. ' - 'Otherwise, the general parameter is used and displayed') + self.parametername.setToolTip( + 'If this is bold then this parameter is only for this data. ' + 'Otherwise, the general parameter is used and displayed' + ) # self.value_line.setValidator(QtGui.QDoubleValidator()) self.value_line.textChanged.connect(lambda: self.valueChanged.emit(self.value) if self.value is not None else 0) diff --git a/src/gui_qt/fit/fitwindow.py b/src/gui_qt/fit/fitwindow.py index 6700493..9aeaed3 100644 --- a/src/gui_qt/fit/fitwindow.py +++ b/src/gui_qt/fit/fitwindow.py @@ -77,8 +77,12 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): """ w = self.param_widgets[idx] self.stackedWidget.removeWidget(w) + w.setParent(None) w.deleteLater() del self.param_widgets[idx] + _, func_id = self.functionwidget.get_selected() + + self.get_functions() self._current_function = None if len(self.param_widgets) == 0: @@ -104,7 +108,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): if function is None: return - dialog = QFitParameterWidget(self.stackedWidget) + dialog = QFitParameterWidget(function_id, self.stackedWidget) data_names = self.data_table.data_list(include_name=True) dialog.set_function(function, function_idx) @@ -206,9 +210,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): for m in self.models[model_id]: func_id = m['cnt'] - self.stackedWidget.removeWidget(self.param_widgets[func_id]) - - self.param_widgets.pop(func_id) + self.remove_function(func_id) self._complex.pop(model_id) self._func_list.pop(model_id)