Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
allow opening of directory on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
tzutalin committed Jan 29, 2018
1 parent 1270b2c commit d43613d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 10 additions & 0 deletions data/predefined_classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 9 additions & 5 deletions labelImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self, defaultFilename=None, defaultPrefdefClassFile=None):
# 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)

Expand Down Expand Up @@ -460,6 +460,10 @@ def xbool(x):
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):
Expand Down Expand Up @@ -1081,20 +1085,20 @@ def openAnnotationDialog(self, _value=False):
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:
Expand Down

1 comment on commit d43613d

@3ookiez
Copy link

@3ookiez 3ookiez commented on d43613d Aug 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.