[FIX]when startup with out specify image, self.filePath will be None, but when loadFile get it, the filePath is 'None', so if there real is a img name as None, it will open it unexceptly
[FIX]when open file, QImageReader.supportedImageFormats() gives items in QbyteArray type, so if do str(fmt) will gives bbmp so that open prompt will not be able to open any thing [FIX]in PyQT5, QFileDialog.getOpenFileName returns a tuple with (filename,filters)
This commit is contained in:
parent
ce853362e5
commit
7460e4316b
@ -442,7 +442,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
self.updateFileMenu()
|
||||
# Since loading the file may take some time, make sure it runs in the
|
||||
# background.
|
||||
self.queueEvent(partial(self.loadFile, self.filePath))
|
||||
self.queueEvent(partial(self.loadFile, self.filePath or ""))
|
||||
|
||||
# Callbacks:
|
||||
self.zoomWidget.valueChanged.connect(self.paintCanvas)
|
||||
@ -1014,13 +1014,14 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
return
|
||||
path = os.path.dirname(str(self.filePath))\
|
||||
if self.filePath else '.'
|
||||
formats = ['*.%s' % str(fmt).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])
|
||||
filename = QFileDialog.getOpenFileName(self,
|
||||
'%s - Choose Image or Label file' % __appname__, path, filters)
|
||||
if filename:
|
||||
if isinstance(filename, (tuple,list)):
|
||||
filename=filename[0]
|
||||
self.loadFile(filename)
|
||||
|
||||
def saveFile(self, _value=False):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user