[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()
|
self.updateFileMenu()
|
||||||
# Since loading the file may take some time, make sure it runs in the
|
# Since loading the file may take some time, make sure it runs in the
|
||||||
# background.
|
# background.
|
||||||
self.queueEvent(partial(self.loadFile, self.filePath))
|
self.queueEvent(partial(self.loadFile, self.filePath or ""))
|
||||||
|
|
||||||
# Callbacks:
|
# Callbacks:
|
||||||
self.zoomWidget.valueChanged.connect(self.paintCanvas)
|
self.zoomWidget.valueChanged.connect(self.paintCanvas)
|
||||||
@ -1014,13 +1014,14 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
return
|
return
|
||||||
path = os.path.dirname(str(self.filePath))\
|
path = os.path.dirname(str(self.filePath))\
|
||||||
if self.filePath else '.'
|
if self.filePath else '.'
|
||||||
formats = ['*.%s' % str(fmt).lower()
|
formats = ['*.%s' % fmt.data().decode("ascii").lower() for fmt in QImageReader.supportedImageFormats()]
|
||||||
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,
|
filename = QFileDialog.getOpenFileName(self,
|
||||||
'%s - Choose Image or Label file' % __appname__, path, filters)
|
'%s - Choose Image or Label file' % __appname__, path, filters)
|
||||||
if filename:
|
if filename:
|
||||||
|
if isinstance(filename, (tuple,list)):
|
||||||
|
filename=filename[0]
|
||||||
self.loadFile(filename)
|
self.loadFile(filename)
|
||||||
|
|
||||||
def saveFile(self, _value=False):
|
def saveFile(self, _value=False):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user