From cbc1761e9fe53beadb09db2bca6c411e18d9a846 Mon Sep 17 00:00:00 2001 From: tzutalin Date: Wed, 27 Sep 2017 18:43:24 +0800 Subject: [PATCH] If there no default saved dir, show a dialog for autosaving --- labelImg.py | 26 +++++++++++++++++--------- libs/settings.py | 2 +- setup.cfg | 2 +- setup.py | 4 ++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/labelImg.py b/labelImg.py index c7a71a3a..a16030b9 100755 --- a/labelImg.py +++ b/labelImg.py @@ -342,7 +342,7 @@ class MainWindow(QMainWindow, WindowMixin): recentFiles=QMenu('Open &Recent'), labelList=labelMenu) - # Auto saving : Enble auto saving if pressing next + # Auto saving : Enable auto saving if pressing next self.autoSaving = QAction("Auto Saving", self) self.autoSaving.setCheckable(True) @@ -1029,7 +1029,7 @@ class MainWindow(QMainWindow, WindowMixin): path = '.' dirpath = ustr(QFileDialog.getExistingDirectory(self, - '%s - Save to the directory' % __appname__, path, QFileDialog.ShowDirsOnly + '%s - Save annotations to the directory' % __appname__, path, QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)) if dirpath is not None and len(dirpath) > 1: @@ -1098,9 +1098,13 @@ class MainWindow(QMainWindow, WindowMixin): def openPrevImg(self, _value=False): # Proceding prev image without dialog if having any label - if self.autoSaving.isChecked() and self.defaultSaveDir is not None: - if self.dirty is True: - self.saveFile() + if self.autoSaving.isChecked(): + if self.defaultSaveDir is not None: + if self.dirty is True: + self.saveFile() + else: + self.changeSavedir() + return if not self.mayContinue(): return @@ -1118,10 +1122,14 @@ class MainWindow(QMainWindow, WindowMixin): self.loadFile(filename) def openNextImg(self, _value=False): - # Proceding next image without dialog if having any label - if self.autoSaving.isChecked() and self.defaultSaveDir is not None: - if self.dirty is True: - self.saveFile() + # Proceding prev image without dialog if having any label + if self.autoSaving.isChecked(): + if self.defaultSaveDir is not None: + if self.dirty is True: + self.saveFile() + else: + self.changeSavedir() + return if not self.mayContinue(): return diff --git a/libs/settings.py b/libs/settings.py index 5490be72..3b5e86f8 100644 --- a/libs/settings.py +++ b/libs/settings.py @@ -7,7 +7,7 @@ class Settings(object): # Be default, the home will be in the same folder as labelImg home = os.path.expanduser("~") self.data = {} - self.path = os.path.join(home, '.settings.pkl') + self.path = os.path.join(home, '.labelImgSettings.pkl') def __setitem__(self, key, value): self.data[key] = value diff --git a/setup.cfg b/setup.cfg index 9d9278c1..99977cac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.5.0 +current_version = 1.5.1 commit = True tag = True diff --git a/setup.py b/setup.py index cee69f4e..fb746937 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ requirements = [ setup( name='labelImg', - version='1.5.0', + version='1.5.1', description="LabelImg is a graphical image annotation tool and label object bounding boxes in images", long_description=readme + '\n\n' + history, author="TzuTa Lin", @@ -46,4 +46,4 @@ setup( 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], -) \ No newline at end of file +)