add support for QT5, fallback to QT4
This commit is contained in:
+12
-4
@@ -1,5 +1,12 @@
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
#from PyQt4.QtOpenGL import *
|
||||
|
||||
from shape import Shape
|
||||
@@ -85,7 +92,7 @@ class Canvas(QWidget):
|
||||
|
||||
def mouseMoveEvent(self, ev):
|
||||
"""Update line with last point and current coordinates."""
|
||||
pos = self.transformPos(ev.posF())
|
||||
pos = self.transformPos(ev.pos())
|
||||
|
||||
self.restoreCursor()
|
||||
|
||||
@@ -169,7 +176,8 @@ class Canvas(QWidget):
|
||||
self.hVertex, self.hShape = None, None
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
pos = self.transformPos(ev.posF())
|
||||
pos = self.transformPos(ev.pos())
|
||||
|
||||
if ev.button() == Qt.LeftButton:
|
||||
if self.drawing():
|
||||
if self.current and self.current.reachMaxPoints() is False:
|
||||
|
||||
+7
-2
@@ -1,5 +1,10 @@
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import QColorDialog, QDialogButtonBox
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
BB = QDialogButtonBox
|
||||
|
||||
|
||||
+24
-6
@@ -1,5 +1,10 @@
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from lib import newIcon, labelValidator
|
||||
|
||||
@@ -32,11 +37,20 @@ class LabelDialog(QDialog):
|
||||
self.setLayout(layout)
|
||||
|
||||
def validate(self):
|
||||
if self.edit.text().trimmed():
|
||||
self.accept()
|
||||
try:
|
||||
if self.edit.text().trimmed():
|
||||
self.accept()
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
if self.edit.text().strip():
|
||||
self.accept()
|
||||
|
||||
def postProcess(self):
|
||||
self.edit.setText(self.edit.text().trimmed())
|
||||
try:
|
||||
self.edit.setText(self.edit.text().trimmed())
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
self.edit.setText(self.edit.text())
|
||||
|
||||
def popUp(self, text='', move=True):
|
||||
self.edit.setText(text)
|
||||
@@ -47,6 +61,10 @@ class LabelDialog(QDialog):
|
||||
return self.edit.text() if self.exec_() else None
|
||||
|
||||
def listItemClick(self, tQListWidgetItem):
|
||||
text = tQListWidgetItem.text().trimmed()
|
||||
try:
|
||||
text = tQListWidgetItem.text().trimmed()
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
text = tQListWidgetItem.text().strip()
|
||||
self.edit.setText(text)
|
||||
self.validate()
|
||||
|
||||
+5
-1
@@ -1,7 +1,11 @@
|
||||
# Copyright (c) 2016 Tzutalin
|
||||
# Create by TzuTaLin <tzu.ta.lin@gmail.com>
|
||||
|
||||
from PyQt4.QtGui import QImage
|
||||
try:
|
||||
from PyQt5.QtGui import QImage
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import QImage
|
||||
|
||||
from base64 import b64encode, b64decode
|
||||
from pascal_voc_io import PascalVocWriter
|
||||
import os.path
|
||||
|
||||
+7
-2
@@ -1,7 +1,12 @@
|
||||
from math import sqrt
|
||||
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
|
||||
def newIcon(icon):
|
||||
|
||||
+7
-2
@@ -1,8 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from lib import distance
|
||||
|
||||
|
||||
+8
-2
@@ -1,5 +1,11 @@
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
|
||||
class ToolBar(QToolBar):
|
||||
def __init__(self, title):
|
||||
|
||||
+7
-2
@@ -1,5 +1,10 @@
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
class ZoomWidget(QSpinBox):
|
||||
def __init__(self, value=100):
|
||||
|
||||
Reference in New Issue
Block a user