Skip to content
Open

PyQt5 #154

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/customrectitemconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt4.QtGui import QPen
from PyQt4.Qt import Qt
from PyQt5.QtGui import QPen
from PyQt5.Qt import Qt
from sloth.items import RectItem


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fullsplit(path, result=None):
description='The Sloth Labeling Tool',
author='CV:HCI Research Group',
url='http://sloth.readthedocs.org/',
requires=['importlib', 'PyQt4', 'numpy'],
requires=['importlib', 'PyQt5', 'numpy'],
packages=packages,
data_files=data_files,
scripts=['sloth/bin/sloth']
Expand Down
7 changes: 4 additions & 3 deletions sloth/annotations/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import logging
import copy
from collections import MutableMapping
from PyQt4.QtGui import QTreeView, QItemSelection, QItemSelectionModel, QSortFilterProxyModel, QBrush
from PyQt4.QtCore import QModelIndex, QAbstractItemModel, Qt, pyqtSignal, QVariant, QObject
from PyQt5.QtWidgets import QTreeView
from PyQt5.QtGui import QBrush
from PyQt5.QtCore import QModelIndex, QAbstractItemModel, QItemSelection, QItemSelectionModel, Qt, pyqtSignal, QVariant, QObject, QSortFilterProxyModel

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -999,7 +1000,7 @@ def interpolateRange(self):
for l in range(len(lann)):
if lann[l]['type'] == fann[i]['type'] and lann[l]['class'] == fann[i]['class']:
lannIdx = l
if lannIdx == None:
if lannIdx is None:
LOG.error("Error: could not find matching label, skipping")
continue

Expand Down
2 changes: 1 addition & 1 deletion sloth/bin/sloth
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from os.path import dirname, realpath
sys.path.insert(1, dirname(dirname(dirname(realpath(__file__)))))
from PyQt4.QtGui import QApplication
from PyQt5.QtWidgets import QApplication
from sloth.core.labeltool import LabelTool
from sloth import APP_NAME, ORGANIZATION_NAME, ORGANIZATION_DOMAIN

Expand Down
10 changes: 6 additions & 4 deletions sloth/core/labeltool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""
import os
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from sloth.annotations.model import *
from sloth.annotations.container import AnnotationContainerFactory, AnnotationContainer
from sloth.conf import config
Expand Down Expand Up @@ -109,7 +110,7 @@ def execute_from_commandline(self, argv=None):
format='%(asctime)s %(levelname)-8s %(name)-30s %(message)s') #, datefmt='%H:%M:%S.%m')

# Disable PyQt log messages
logging.getLogger("PyQt4").setLevel(logging.WARNING)
logging.getLogger("PyQt5").setLevel(logging.WARNING)

# Handle options common for all commands
# and initialize the labeltool object from
Expand Down Expand Up @@ -150,6 +151,7 @@ def execute_from_commandline(self, argv=None):
else:
# Setup GUI
self._mainwindow = MainWindow(self)
self._mainwindow.doinit()
self._mainwindow.show()

# Load plugins
Expand Down Expand Up @@ -448,4 +450,4 @@ def treeview(self):
if self._mainwindow is None:
return None
else:
return self._mainwindow.treeview
return self._mainwindow.treeview
4 changes: 2 additions & 2 deletions sloth/gui/buttonarea.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from sloth.gui.floatinglayout import FloatingLayout
import logging

Expand Down
6 changes: 3 additions & 3 deletions sloth/gui/controlbuttons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PyQt4.QtGui import *
from PyQt4.QtCore import *

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class Label(QLabel):

Expand Down
4 changes: 2 additions & 2 deletions sloth/gui/floatinglayout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt4.QtCore import Qt, QRect, QSize, QPoint
from PyQt4.QtGui import QLayout, QSizePolicy, QWidgetItem
from PyQt5.QtCore import Qt, QRect, QSize, QPoint
from PyQt5.QtWidgets import QLayout, QSizePolicy, QWidgetItem


class FloatingLayout(QLayout):
Expand Down
7 changes: 4 additions & 3 deletions sloth/gui/frameviewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import math
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
try:
import okapy.videoio
except ImportError:
Expand Down Expand Up @@ -96,7 +97,7 @@ def setScaleRelative(self, factor):
self.setScaleAbsolute(self.getScale() * factor)

def wheelEvent(self, event):
factor = 1.41 ** (event.delta() / 240.0)
factor = 1.41 ** (event.angleDelta().y() / 240.0)
self.setScaleRelative(factor)

def focusInEvent(self, event):
Expand Down
19 changes: 11 additions & 8 deletions sloth/gui/labeltool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import logging, os
import functools
import fnmatch
from PyQt4.QtGui import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QKeySequence, QLabel, QItemSelectionModel, QMessageBox, QFileDialog, QFrame, \
from PyQt5.QtWidgets import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QLabel, QMessageBox, QFileDialog, QFrame, \
QDockWidget, QProgressBar, QProgressDialog
from PyQt4.QtCore import SIGNAL, QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject
import PyQt4.uic as uic
from PyQt5.QtGui import QKeySequence
from PyQt5.QtCore import QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject, QItemSelectionModel
import PyQt5.uic as uic
from sloth.gui import qrc_icons # needed for toolbar icons
from sloth.gui.propertyeditor import PropertyEditor
from sloth.gui.annotationscene import AnnotationScene
Expand Down Expand Up @@ -70,6 +71,8 @@ def __init__(self, labeltool, parent=None):
self.loader = None

self.labeltool = labeltool

def doinit(self):
self.setupGui()
self.loadApplicationSettings()
self.onAnnotationsLoaded()
Expand Down Expand Up @@ -129,7 +132,7 @@ def onCurrentImageChanged(self):

img = self.labeltool.getImage(new_image)

if img == None:
if img is None:
self.controls.setFilename("")
self.selectionmodel.setCurrentIndex(new_image.index(), QItemSelectionModel.ClearAndSelect|QItemSelectionModel.Rows)
return
Expand Down Expand Up @@ -399,7 +402,7 @@ def fileOpen(self):
format_str = ' '.join(self.labeltool.getAnnotationFilePatterns())
fname = QFileDialog.getOpenFileName(self,
"%s - Load Annotations" % APP_NAME, path,
"%s annotation files (%s)" % (APP_NAME, format_str))
"%s annotation files (%s)" % (APP_NAME, format_str))[0]
if len(str(fname)) > 0:
self.labeltool.loadAnnotations(fname)

Expand All @@ -414,7 +417,7 @@ def fileSaveAs(self):
format_str = ' '.join(self.labeltool.getAnnotationFilePatterns())
fname = QFileDialog.getSaveFileName(self,
"%s - Save Annotations" % APP_NAME, fname,
"%s annotation files (%s)" % (APP_NAME, format_str))
"%s annotation files (%s)" % (APP_NAME, format_str))[0]

if len(str(fname)) > 0:
return self.labeltool.saveAnnotations(str(fname))
Expand All @@ -429,7 +432,7 @@ def addMediaFile(self):
image_types = [ '*.jpg', '*.bmp', '*.png', '*.pgm', '*.ppm', '*.tiff', '*.tif', '*.gif' ]
video_types = [ '*.mp4', '*.mpg', '*.mpeg', '*.avi', '*.mov', '*.vob' ]
format_str = ' '.join(image_types + video_types)
fnames = QFileDialog.getOpenFileNames(self, "%s - Add Media File" % APP_NAME, path, "Media files (%s)" % (format_str, ))
fnames = QFileDialog.getOpenFileNames(self, "%s - Add Media File" % APP_NAME, path, "Media files (%s)" % (format_str, ))[0]

item = None
numFiles = len(fnames)
Expand Down
5 changes: 3 additions & 2 deletions sloth/gui/propertyeditor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import time
import logging
from PyQt4.QtCore import pyqtSignal, QSize, Qt
from PyQt4.QtGui import QWidget, QGroupBox, QVBoxLayout, QPushButton, QScrollArea, QLineEdit, QDoubleValidator, QIntValidator, QShortcut, QKeySequence
from PyQt5.QtCore import pyqtSignal, QSize, Qt
from PyQt5.QtWidgets import QWidget, QGroupBox, QVBoxLayout, QPushButton, QScrollArea, QLineEdit, QShortcut
from PyQt5.QtGui import QDoubleValidator, QIntValidator, QKeySequence
from sloth.core.exceptions import ImproperlyConfigured
from sloth.annotations.model import AnnotationModelItem
from sloth.gui.floatinglayout import FloatingLayout
Expand Down
2 changes: 1 addition & 1 deletion sloth/gui/qrc_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore
from PyQt5 import QtCore

qt_resource_data = b"\
\x00\x00\x02\xb3\
Expand Down
4 changes: 2 additions & 2 deletions sloth/gui/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt4.QtCore import QSize
from PyQt4.QtGui import QVBoxLayout
from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QVBoxLayout


# This is really really ugly, but the QDockWidget for some reason does not notice when
Expand Down
4 changes: 2 additions & 2 deletions sloth/items/inserters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import math
from PyQt4.QtGui import *
from PyQt4.Qt import *
from PyQt5.QtGui import *
from PyQt5.Qt import *


class ItemInserter(QObject):
Expand Down
2 changes: 1 addition & 1 deletion sloth/items/items.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from PyQt4.Qt import *
from PyQt5.Qt import *


LOG = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions sloth/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import logging


Expand Down
4 changes: 2 additions & 2 deletions sloth/plugins/facedetector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from sloth.annotations.model import ImageModelItem
from okapy import BinaryPatternFaceDetector

Expand Down
2 changes: 1 addition & 1 deletion sloth/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import random
import colorsys
from PyQt4.QtGui import QImage, qRgb
from PyQt5.QtGui import QImage, qRgb
from sloth.core.exceptions import NotImplementedException


Expand Down
2 changes: 1 addition & 1 deletion tests/model_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
import os, sys
from PyQt4.QtGui import QApplication
from PyQt5.QtWidgets import QApplication
from sloth.gui import MainWindow
from sloth.core.labeltool import LabelTool
from sloth import APP_NAME, ORGANIZATION_NAME, ORGANIZATION_DOMAIN
Expand Down
2 changes: 1 addition & 1 deletion tests/pymodeltest/modeltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#############################################################################

import sip
from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtGui


class ModelTest(QtCore.QObject):
Expand Down