From ef13a1ede5aa37ad11c72bdf0bbea7ecd15d01aa Mon Sep 17 00:00:00 2001 From: tzutalin Date: Thu, 9 Mar 2017 13:18:55 +0800 Subject: [PATCH] Use u() functions to convert string for python2/3 --- labelImg.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/labelImg.py b/labelImg.py index fd935ac0..8ce5996a 100644 --- a/labelImg.py +++ b/labelImg.py @@ -1033,16 +1033,13 @@ class MainWindow(QMainWindow, WindowMixin): def openFile(self, _value=False): if not self.mayContinue(): return - path = os.path.dirname(str(self.filePath))\ - if self.filePath else '.' + path = os.path.dirname(u(self.filePath)) if self.filePath else '.' formats = ['*.%s' % fmt.data().decode("ascii").lower() for fmt in QImageReader.supportedImageFormats()] - filters = "Image & Label files (%s)" % \ - ' '.join(formats + ['*%s' % LabelFile.suffix]) - filename = QFileDialog.getOpenFileName(self, - '%s - Choose Image or Label file' % __appname__, path, filters) + filters = "Image & Label files (%s)" % ' '.join(formats + ['*%s' % LabelFile.suffix]) + filename = QFileDialog.getOpenFileName(self, '%s - Choose Image or Label file' % __appname__, path, filters) if filename: - if isinstance(filename, (tuple,list)): - filename=filename[0] + if isinstance(filename, (tuple, list)): + filename = filename[0] self.loadFile(filename) def saveFile(self, _value=False):