stop autoamtic ascii reading if first is cancelled

This commit is contained in:
Dominik Demuth 2024-04-02 17:33:38 +02:00
parent 403273e0d7
commit c9b1109dbc
2 changed files with 12 additions and 5 deletions

View File

@ -178,7 +178,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
@QtCore.pyqtSlot()
def accept(self):
if self.apply():
self.close()
super().accept()
def apply(self):
# default row for x is the first row, it will be superseded if an integer number is given.

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from pathlib import Path
import struct
from ..Qt import QtCore
from ..Qt import QtCore, QtWidgets
from .asciireader import QAsciiReader
from .hdfreader import QHdfViewer
from .bdsreader import QBDSReader
@ -26,8 +26,12 @@ class QFileReader(QtCore.QObject):
self.reader = {}
for ext, reader in [
('txt', QAsciiReader), ('dsc', QDSCReader), ('agr', QGraceReader),
('bds', QBDSReader), ('hdf', QHdfViewer), ('nmr', QNMRReader)
('txt', QAsciiReader),
('dsc', QDSCReader),
('agr', QGraceReader),
('bds', QBDSReader),
('hdf', QHdfViewer),
('nmr', QNMRReader),
]:
self.register(ext, reader)
@ -57,7 +61,10 @@ class QFileReader(QtCore.QObject):
try:
# If QAsciiReader.skip = True it accepts automatically and returns None
r(f).exec()
status = r(f).exec()
if status == QtWidgets.QDialog.Rejected and isinstance(r, QAsciiReader):
break
except AttributeError:
pass