disable validators

This commit is contained in:
Dominik Demuth 2023-09-06 17:45:57 +02:00
parent 311157a01a
commit 53c58b2bbb
3 changed files with 17 additions and 11 deletions

View File

@ -19,9 +19,9 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter):
self.parametername.setText(label + ' ') self.parametername.setText(label + ' ')
validator = QtGui.QDoubleValidator() # validator = QtGui.QDoubleValidator()
validator.setDecimals(9) # validator.setDecimals(9)
self.parameter_line.setValidator(validator) # self.parameter_line.setValidator(validator)
self.parameter_line.setText('1') self.parameter_line.setText('1')
self.parameter_line.setMaximumWidth(60) self.parameter_line.setMaximumWidth(60)
self.lineEdit.setMaximumWidth(60) self.lineEdit.setMaximumWidth(60)
@ -97,10 +97,11 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter):
try: try:
p = float(self.parameter_line.text().replace(',', '.')) p = float(self.parameter_line.text().replace(',', '.'))
except ValueError: except ValueError:
_ = QtWidgets.QMessageBox().warning(self, 'Invalid value', p = self.parameter_line.text().replace(',', '.')
f'{self.parametername.text()} contains invalid values', # _ = QtWidgets.QMessageBox().warning(self, 'Invalid value',
QtWidgets.QMessageBox.Cancel) # f'{self.parametername.text()} contains invalid values',
return None # QtWidgets.QMessageBox.Cancel)
# return None
if self.checkBox.isChecked(): if self.checkBox.isChecked():
try: try:

View File

@ -124,10 +124,12 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit):
if idx is None: if idx is None:
idx = self.global_parameter.index(self.sender()) idx = self.global_parameter.index(self.sender())
self.glob_values[idx] = float(value) # self.glob_values[idx] = float(value)
self.glob_values[idx] = value
if self.data_values[self.comboBox.currentData()][idx] is None: if self.data_values[self.comboBox.currentData()][idx] is None:
self.data_parameter[idx].blockSignals(True) self.data_parameter[idx].blockSignals(True)
self.data_parameter[idx].value = float(value) # self.data_parameter[idx].value = float(value)
self.data_parameter[idx].value = value
self.data_parameter[idx].blockSignals(False) self.data_parameter[idx].blockSignals(False)
@QtCore.pyqtSlot(str, object) @QtCore.pyqtSlot(str, object)
@ -300,7 +302,7 @@ class ParameterSingleWidget(QtWidgets.QWidget):
self.label.setText(convert(name)) self.label.setText(convert(name))
self.label.setToolTip('IIf this is bold then this parameter is only for this data. otherwise the general parameter is used and displayed') self.label.setToolTip('IIf 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.setValidator(QtGui.QDoubleValidator())
self.value_line.textChanged.connect(lambda: self.valueChanged.emit(self.value) if self.value is not None else 0) self.value_line.textChanged.connect(lambda: self.valueChanged.emit(self.value) if self.value is not None else 0)
self.reset_button.clicked.connect(lambda x: self.removeSingleValue.emit()) self.reset_button.clicked.connect(lambda x: self.removeSingleValue.emit())
@ -334,7 +336,8 @@ class ParameterSingleWidget(QtWidgets.QWidget):
@value.setter @value.setter
def value(self, val): def value(self, val):
self.value_line.setText(f'{float(val):.5g}') # self.value_line.setText(f'{float(val):.5g}')
self.value_line.setText(f'{val}')
def show_as_local_parameter(self, is_local): def show_as_local_parameter(self, is_local):
if is_local: if is_local:

View File

@ -223,6 +223,8 @@ class FitRoutine(object):
def run(self, mode: str = 'lsq'): def run(self, mode: str = 'lsq'):
self._abort = False self._abort = False
print('run')
fit_groups, linked_parameter = self.prepare_links() fit_groups, linked_parameter = self.prepare_links()
for data_groups in fit_groups: for data_groups in fit_groups:
if len(data_groups) == 1 and not self.linked: if len(data_groups) == 1 and not self.linked: