From af0e0fc76f797671b6ba1dbc1f43112f4d582908 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 13 Dec 2023 19:10:01 +0000 Subject: [PATCH] #177 (#178) closes issue #177 --- src/gui_qt/data/point_select.py | 2 +- src/gui_qt/io/asciireader.py | 2 +- src/gui_qt/main/mainwindow.py | 7 +++++-- src/nmreval/io/asciireader.py | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui_qt/data/point_select.py b/src/gui_qt/data/point_select.py index 514ba49..512e5e8 100644 --- a/src/gui_qt/data/point_select.py +++ b/src/gui_qt/data/point_select.py @@ -199,4 +199,4 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form): @QtCore.pyqtSlot(int, name='on_graph_checkbox_stateChanged') def changed_state(self, checked): - self.graph_combobox.setEnabled(checked!=QtCore.Qt.Checked) + self.graph_combobox.setEnabled(checked != QtCore.Qt.Checked) diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py index b6e78de..8cbbd37 100644 --- a/src/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -211,7 +211,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): col_header.append(i) if y is not None and col_header is not None: - col_header = [col_header[i] for i in range(len(col_header)) if i in y] + col_header = [col_header[i] for i in range(len(col_header))] try: ret_dic = self.reader.export( diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 6af00a7..8e439a2 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -259,8 +259,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): filedialog.set_graphs(self.management.graphs.list()) - filedialog.exec() - fname = filedialog.selectedFiles() + accepted = filedialog.exec() + if accepted: + fname = filedialog.selectedFiles() + else: + fname = [] if fname: self.path = Path(fname[0]).parent diff --git a/src/nmreval/io/asciireader.py b/src/nmreval/io/asciireader.py index 6e9ceb3..e8c0b4f 100644 --- a/src/nmreval/io/asciireader.py +++ b/src/nmreval/io/asciireader.py @@ -121,6 +121,9 @@ class AsciiReader: if y is None: y = list(range(int(len(x) != 0), max(self.width))) + if col_names is not None: + col_names = [col_names[y_i] for y_i in y] + cols = x + y + yerr with self.fname.open('rb') as fh: tmp_ = re.sub(b'[;,]', b' ', fh.read())