Add Silent option for openDirDialog
Add Silent option for openDirDialog to facilitate opening a directory at start up
if the filePath provided is a directory without opening the file selector UI.
This commit is contained in:
parent
53a78e2c93
commit
157a4173f3
13
labelImg.py
13
labelImg.py
@ -474,7 +474,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
|
||||
# Open Dir if deafult file
|
||||
if self.filePath and os.path.isdir(self.filePath):
|
||||
self.openDirDialog(dirpath=self.filePath)
|
||||
self.openDirDialog(dirpath=self.filePath, silent=True)
|
||||
|
||||
def keyReleaseEvent(self, event):
|
||||
if event.key() == Qt.Key_Control:
|
||||
@ -1170,7 +1170,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
filename = filename[0]
|
||||
self.loadPascalXMLByFilename(filename)
|
||||
|
||||
def openDirDialog(self, _value=False, dirpath=None):
|
||||
def openDirDialog(self, _value=False, dirpath=None, silent=False):
|
||||
if not self.mayContinue():
|
||||
return
|
||||
|
||||
@ -1179,10 +1179,13 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
defaultOpenDirPath = self.lastOpenDir
|
||||
else:
|
||||
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
|
||||
if silent!=True :
|
||||
targetDirPath = ustr(QFileDialog.getExistingDirectory(self,
|
||||
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
||||
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
||||
else:
|
||||
targetDirPath = ustr(defaultOpenDirPath)
|
||||
|
||||
targetDirPath = ustr(QFileDialog.getExistingDirectory(self,
|
||||
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
||||
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
||||
self.importDirImages(targetDirPath)
|
||||
|
||||
def importDirImages(self, dirpath):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user