From d43613d9c4a0fa8acce9157654567176644c000d Mon Sep 17 00:00:00 2001 From: tzutalin Date: Mon, 29 Jan 2018 15:45:40 +0800 Subject: [PATCH] allow opening of directory on launch --- data/predefined_classes.txt | 10 ++++++++++ labelImg.py | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/data/predefined_classes.txt b/data/predefined_classes.txt index 94a82c14..bc2eef13 100644 --- a/data/predefined_classes.txt +++ b/data/predefined_classes.txt @@ -3,3 +3,13 @@ person cat tv car +meatballs +marinara sauce +tomato soup +chicken noodle soup +french onion soup +chicken breast +ribs +pulled pork +hamburger +cavity \ No newline at end of file diff --git a/labelImg.py b/labelImg.py index 8e6c8152..a817a653 100755 --- a/labelImg.py +++ b/labelImg.py @@ -199,7 +199,7 @@ class MainWindow(QMainWindow, WindowMixin): # Tzutalin 20160906 : Add file list and dock to move faster self.addDockWidget(Qt.RightDockWidgetArea, self.filedock) self.filedock.setFeatures(QDockWidget.DockWidgetFloatable) - + self.dockFeatures = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable self.dock.setFeatures(self.dock.features() ^ self.dockFeatures) @@ -460,6 +460,10 @@ class MainWindow(QMainWindow, WindowMixin): self.labelCoordinates = QLabel('') self.statusBar().addPermanentWidget(self.labelCoordinates) + # Open Dir if deafult file + if self.filePath and os.path.isdir(self.filePath): + self.openDirDialog(dirpath=self.filePath) + ## Support Functions ## def noShapes(self): @@ -1081,20 +1085,20 @@ class MainWindow(QMainWindow, WindowMixin): filename = filename[0] self.loadPascalXMLByFilename(filename) - def openDirDialog(self, _value=False): + def openDirDialog(self, _value=False, dirpath=None): if not self.mayContinue(): return - defaultOpenDirPath = '.' + defaultOpenDirPath = dirpath if dirpath else '.' if self.lastOpenDir and os.path.exists(self.lastOpenDir): defaultOpenDirPath = self.lastOpenDir else: defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.' - dirpath = ustr(QFileDialog.getExistingDirectory(self, + targetDirPath = ustr(QFileDialog.getExistingDirectory(self, '%s - Open Directory' % __appname__, defaultOpenDirPath, QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)) - self.importDirImages(dirpath) + self.importDirImages(targetDirPath) def importDirImages(self, dirpath): if not self.mayContinue() or not dirpath: