From d83e1125153fd432c4acd5d671e04b329a0747ff Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 11 Jan 2024 12:39:03 +0000 Subject: [PATCH] bugfixes-022024 (#211) Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/211 --- src/gui_qt/_py/fcreader.py | 15 +++++++------ src/gui_qt/fit/result.py | 4 ---- src/gui_qt/io/fcbatchreader.py | 39 +++++++++++++++++++++------------- src/resources/_ui/fcreader.ui | 11 ++++++++-- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/gui_qt/_py/fcreader.py b/src/gui_qt/_py/fcreader.py index 766c641..041a46c 100644 --- a/src/gui_qt/_py/fcreader.py +++ b/src/gui_qt/_py/fcreader.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'resources/_ui/fcreader.ui' +# Form implementation generated from reading ui file 'src/resources/_ui/fcreader.ui' # -# Created by: PyQt5 UI code generator 5.12.3 +# Created by: PyQt5 UI code generator 5.15.10 # -# WARNING! All changes made in this file will be lost! +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets @@ -47,6 +48,7 @@ class Ui_FCEval_dialog(object): self.verticalLayout.addWidget(self.input_box) self.region_box = QtWidgets.QGroupBox(FCEval_dialog) self.region_box.setCheckable(True) + self.region_box.setChecked(False) self.region_box.setObjectName("region_box") self.horizontalLayout = QtWidgets.QHBoxLayout(self.region_box) self.horizontalLayout.setContentsMargins(3, 3, 3, 3) @@ -139,6 +141,7 @@ class Ui_FCEval_dialog(object): self.line.setObjectName("line") self.gridLayout.addWidget(self.line, 2, 0, 1, 2) self.graph_comboBox = QtWidgets.QComboBox(self.out_box) + self.graph_comboBox.setEnabled(False) self.graph_comboBox.setObjectName("graph_comboBox") self.gridLayout.addWidget(self.graph_comboBox, 3, 1, 1, 1) self.graph_checkbox = QtWidgets.QCheckBox(self.out_box) @@ -167,8 +170,8 @@ class Ui_FCEval_dialog(object): self.label_6.setBuddy(self.m0_cb) self.retranslateUi(FCEval_dialog) - self.buttonBox.accepted.connect(FCEval_dialog.accept) - self.buttonBox.rejected.connect(FCEval_dialog.reject) + self.buttonBox.accepted.connect(FCEval_dialog.accept) # type: ignore + self.buttonBox.rejected.connect(FCEval_dialog.reject) # type: ignore QtCore.QMetaObject.connectSlotsByName(FCEval_dialog) def retranslateUi(self, FCEval_dialog): @@ -178,7 +181,7 @@ class Ui_FCEval_dialog(object): self.file_pushbutton.setText(_translate("FCEval_dialog", "Add HDF files...")) self.dir_pushbutton.setText(_translate("FCEval_dialog", "Add directory...")) self.overwrite_cb.setText(_translate("FCEval_dialog", "Overwrite prev. data")) - self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to start/end)")) + self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to values of the script)")) self.start_lineedit.setPlaceholderText(_translate("FCEval_dialog", "start pos in µs")) self.stop_lineedit.setPlaceholderText(_translate("FCEval_dialog", "end pos in µs")) self.fit_box.setTitle(_translate("FCEval_dialog", "Fit equation")) diff --git a/src/gui_qt/fit/result.py b/src/gui_qt/fit/result.py index 01f44ee..eeaa56b 100644 --- a/src/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -229,20 +229,16 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.fit_plot.enableAutoRange() def _plot_residuals(self, idx: str = None): - print(idx) if idx is None or isinstance(idx, QtWidgets.QAbstractButton): idx = self.sets_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole) res = self._results[idx] if res.iscomplex: if self.rel_dev_button.isChecked(): - print('rel') self.resid_graph.setData(x=res.x_data, y=res.residual.real/np_abs(res.y_data.real)) - print(res.y_data.imag) if all(np_isfinite(res.y_data.imag)): self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag/np_abs(res.y_data.imag)) else: - print('abs') self.resid_graph.setData(x=res.x_data, y=res.residual.real) self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag) diff --git a/src/gui_qt/io/fcbatchreader.py b/src/gui_qt/io/fcbatchreader.py index 4f678b5..c4bb80b 100644 --- a/src/gui_qt/io/fcbatchreader.py +++ b/src/gui_qt/io/fcbatchreader.py @@ -22,14 +22,16 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): self.start_lineedit.setValidator(QtGui.QDoubleValidator()) self.stop_lineedit.setValidator(QtGui.QDoubleValidator()) - self.graph_checkbox.stateChanged.connect(lambda x: self.graph_comboBox.setEnabled(not bool(x))) + self.graph_checkbox.stateChanged.connect( + lambda x: self.graph_comboBox.setEnabled(x == QtCore.Qt.CheckState.Unchecked) + ) self.listWidget.installEventFilter(self) def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool: # intercept key press in listwidget to allow deletion with Del - if evt.type() == QtCore.QEvent.KeyPress: - if evt.key() == QtCore.Qt.Key_Delete: + if evt.type() == QtCore.QEvent.Type.KeyPress: + if evt.key() == QtCore.Qt.Key.Key_Delete: self.listWidget.takeItem(self.listWidget.currentRow()) return True @@ -41,21 +43,25 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): @QtCore.pyqtSlot(int, name='on_region_checkBox_stateChanged') def use_region(self, state: int): - self.start_lineedit.setEnabled(state == QtCore.Qt.Checked) - self.stop_lineedit.setEnabled(state == QtCore.Qt.Checked) + self.start_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked) + self.stop_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked) @QtCore.pyqtSlot(name='on_file_pushbutton_clicked') @QtCore.pyqtSlot(name='on_dir_pushbutton_clicked') def get_input(self): if self.sender() == self.file_pushbutton: - infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(caption='Select HDF files', - directory=str(self.path), - filter='HDF files (*.h5)') + infiles, _ = QtWidgets.QFileDialog.getOpenFileNames( + caption='Select HDF files', + directory=str(self.path), + filter='HDF files (*.h5)', + ) else: - infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory', - directory=str(self.path), - options=QtWidgets.QFileDialog.ShowDirsOnly) + infiles = QtWidgets.QFileDialog.getExistingDirectory( + caption='Select input directory', + directory=str(self.path), + options=QtWidgets.QFileDialog.ShowDirsOnly, + ) infiles = [infiles] if infiles else infiles if infiles: @@ -65,9 +71,12 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): @QtCore.pyqtSlot(name='on_savebutton_clicked') def save_path(self): - outfile = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select directory', - directory=self.label.text(), - options=QtWidgets.QFileDialog.ShowDirsOnly) + outfile = QtWidgets.QFileDialog.getExistingDirectory( + self, + caption='Select directory', + directory=self.label.text(), + options=QtWidgets.QFileDialog.ShowDirsOnly, + ) if outfile: self.label.setText(outfile) @@ -110,6 +119,6 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): grp = '' if not self.graph_checkbox.isChecked(): - grp = self.graph_comboBox.currentData(QtCore.Qt.UserRole) + grp = self.graph_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole) self.data_read.emit(ret_vals, grp) diff --git a/src/resources/_ui/fcreader.ui b/src/resources/_ui/fcreader.ui index 7c818de..ff4695c 100644 --- a/src/resources/_ui/fcreader.ui +++ b/src/resources/_ui/fcreader.ui @@ -96,11 +96,14 @@ - Evaluate region (empty values default to start/end) + Evaluate region (empty values default to values of the script) true + + false + 3 @@ -311,7 +314,11 @@ - + + + false + +