From e5563d55d5a48772698b72b6405e5b5a17874ee4 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Fri, 14 Apr 2023 17:58:14 +0200 Subject: [PATCH] set graphs in fc reader --- src/gui_qt/io/fcbatchreader.py | 17 +++++++++++------ src/gui_qt/main/mainwindow.py | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui_qt/io/fcbatchreader.py b/src/gui_qt/io/fcbatchreader.py index 007de7e..c94dfed 100644 --- a/src/gui_qt/io/fcbatchreader.py +++ b/src/gui_qt/io/fcbatchreader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pathlib from nmreval.io.fcbatchreader import FCReader @@ -31,6 +33,10 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): return super().eventFilter(src, evt) + def add_graphs(self, graphs: list[tuple[str, str]]): + for gid, graph_name in graphs: + self.graph_comboBox.addItem(graph_name, gid) + @QtCore.pyqtSlot(int, name='on_region_checkBox_stateChanged') def use_region(self, state: int): self.start_lineedit.setEnabled(state == QtCore.Qt.Checked) @@ -43,17 +49,16 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog): infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(caption='Select HDF files', directory=str(self.path), filter='HDF files (*.h5)') - if infiles: - self.listWidget.addItems(infiles) - self.label.setText(str(pathlib.Path(infiles[-1]).parent)) + else: infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory', directory=str(self.path), options=QtWidgets.QFileDialog.ShowDirsOnly) - if infiles: - self.listWidget.addItem(infiles) - self.label.setText(str(pathlib.Path(infiles).parent)) + if infiles: + self.listWidget.addItems(infiles) + self.path = pathlib.Path(infiles[-1]).parent + self.label.setText(str(self.path)) @QtCore.pyqtSlot(name='on_savebutton_clicked') def save_path(self): diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 77bc0c2..29fa278 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -254,6 +254,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @QtCore.pyqtSlot(name='on_actionOpen_FC_triggered') def read_fc(self): reader = QFCReader(path=self.path, parent=self) + reader.add_graphs(self.management.graphs.list()) reader.data_read.connect(self.management.add_new_data) reader.exec()