From fae19e20b92e6595c7b66813bbee581537a7aad5 Mon Sep 17 00:00:00 2001 From: Markus Roth Date: Mon, 12 Mar 2012 13:42:17 -0700 Subject: [PATCH 1/3] Add functions to select all items (the typical Ctrl + a action). --- sloth/core/labeltool.py | 4 ++++ sloth/gui/annotationscene.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sloth/core/labeltool.py b/sloth/core/labeltool.py index d1a0b9a..df758c8 100755 --- a/sloth/core/labeltool.py +++ b/sloth/core/labeltool.py @@ -429,6 +429,10 @@ class LabelTool(QObject): def selectPreviousAnnotation(self): if self._mainwindow is not None: return self._mainwindow.scene.selectNextItem(reverse=True) + + def selectAllAnnotations(self): + if self._mainwindow is not None: + return self._mainwindow.scene.selectAllItems() def deleteSelectedAnnotations(self): if self._mainwindow is not None: diff --git a/sloth/gui/annotationscene.py b/sloth/gui/annotationscene.py index e9a56bb..52981de 100644 --- a/sloth/gui/annotationscene.py +++ b/sloth/gui/annotationscene.py @@ -260,6 +260,10 @@ class AnnotationScene(QGraphicsScene): item.setSelected(True) break + def selectAllItems(self): + for item in self.items(): + item.setSelected(True) + def keyPressEvent(self, event): LOG.debug("keyPressEvent %s" % event) From d0afb915e321a16320aaf4e861b921f94b0ee180 Mon Sep 17 00:00:00 2001 From: Markus Roth Date: Mon, 12 Mar 2012 13:43:25 -0700 Subject: [PATCH 2/3] Ignore gedit swap files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 15c4573..a157b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ doc/_build/* *.pyc .*.swp +*.py~ build/* From 5cee1d4a316c1a7ca052b7eb9dbc6a20ed11e45a Mon Sep 17 00:00:00 2001 From: Mika Fischer Date: Wed, 21 Mar 2012 17:42:24 +0100 Subject: [PATCH 3/3] Consistently use next() free function to get next element --- sloth/core/labeltool.py | 4 ++-- sloth/gui/labeltool.py | 5 +---- sloth/gui/propertyeditor.py | 6 +----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/sloth/core/labeltool.py b/sloth/core/labeltool.py index df758c8..9c231b7 100755 --- a/sloth/core/labeltool.py +++ b/sloth/core/labeltool.py @@ -287,7 +287,7 @@ class LabelTool(QObject): current = self._current_image if current is None: - current = self._model.iterator(ImageModelItem).next() + current = next(self._model.iterator(ImageModelItem)) next_image = current.getSibling(idx) if next_image is not None: @@ -298,7 +298,7 @@ class LabelTool(QObject): if self._current_image is not None: next_image = self._current_image.getNextSibling(step) else: - next_image = self._model.iterator(ImageModelItem).next() + next_image = next(self._model.iterator(ImageModelItem)) if next_image is not None: next_image = next_image.getNextSibling(step-1) diff --git a/sloth/gui/labeltool.py b/sloth/gui/labeltool.py index b1a0793..90caa31 100755 --- a/sloth/gui/labeltool.py +++ b/sloth/gui/labeltool.py @@ -48,10 +48,7 @@ class BackgroundLoader(QObject): self._message_displayed = True if self._level <= self._max_levels and self._rows > 0: try: - if hasattr(self._iterator, "next"): - item = self._iterator.next() - else: - item = next(self._iterator) + item = next(self._iterator) self._next_rows += item.rowCount() self._pos += 1 self._progress.setValue(int((float(self._pos) / float(self._rows) + self._level - 1) * 1000)) diff --git a/sloth/gui/propertyeditor.py b/sloth/gui/propertyeditor.py index 56e0f83..482c781 100644 --- a/sloth/gui/propertyeditor.py +++ b/sloth/gui/propertyeditor.py @@ -179,11 +179,7 @@ class DefaultAttributeHandler(QGroupBox, AbstractAttributeHandler): self._inputField.setPlaceholderText(", ".join(selected_values)) elif len(selected_values) == 1: it = iter(selected_values) - if hasattr(it, 'next'): - self._inputField.setText(it.next()) - else: - self._inputField.setText(next(it)) - + self._inputField.setText(next(it)) def updateButtons(self): selected_values = self.getSelectedValues()