[tested]Fixed open file dialog cancel error. (#856)

* Fix

Error "IndexError: list index out of range"  occurs when there is no "predefined_classes.txt".

* Fix an error when default label is null.

Error "IndexError: list index out of range"  occurs when there is no "/data/predefined_classes.txt".

* Update README.rst

ADD: Package as a separate exe file method.

* Fixed an error after opening a file to cancel

The cause of the error:
QFileDialog.getOpenFileName(...) second parameter required cannot be empty.
This commit is contained in:
PTA00 2022-03-09 13:53:45 +08:00 committed by GitHub
parent 9e4a4b711e
commit 0bc7a462d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1391,7 +1391,7 @@ class MainWindow(QMainWindow, WindowMixin):
path = os.path.dirname(ustr(self.file_path)) if self.file_path else '.' path = os.path.dirname(ustr(self.file_path)) if self.file_path else '.'
formats = ['*.%s' % fmt.data().decode("ascii").lower() for fmt in QImageReader.supportedImageFormats()] formats = ['*.%s' % fmt.data().decode("ascii").lower() for fmt in QImageReader.supportedImageFormats()]
filters = "Image & Label files (%s)" % ' '.join(formats + ['*%s' % LabelFile.suffix]) filters = "Image & Label files (%s)" % ' '.join(formats + ['*%s' % LabelFile.suffix])
filename = QFileDialog.getOpenFileName(self, '%s - Choose Image or Label file' % __appname__, path, filters) filename,_ = QFileDialog.getOpenFileName(self, '%s - Choose Image or Label file' % __appname__, path, filters)
if filename: if filename:
if isinstance(filename, (tuple, list)): if isinstance(filename, (tuple, list)):
filename = filename[0] filename = filename[0]