diff --git a/.gitignore b/.gitignore index 15c4573..a157b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ doc/_build/* *.pyc .*.swp +*.py~ build/* diff --git a/sloth/core/labeltool.py b/sloth/core/labeltool.py index d1a0b9a..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) @@ -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) 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()