Use u() functions to convert string for python2/3

This commit is contained in:
tzutalin 2017-03-09 13:18:55 +08:00
parent 634fc0c637
commit ef13a1ede5

View File

@ -1033,16 +1033,13 @@ class MainWindow(QMainWindow, WindowMixin):
def openFile(self, _value=False): def openFile(self, _value=False):
if not self.mayContinue(): if not self.mayContinue():
return return
path = os.path.dirname(str(self.filePath))\ path = os.path.dirname(u(self.filePath)) if self.filePath else '.'
if self.filePath 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)" % \ filters = "Image & Label files (%s)" % ' '.join(formats + ['*%s' % LabelFile.suffix])
' '.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]
self.loadFile(filename) self.loadFile(filename)
def saveFile(self, _value=False): def saveFile(self, _value=False):