From 3ce7f58384a8dd1204365925f5437afbde14b7c3 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 17 Jan 2021 06:45:19 +0800 Subject: [PATCH] import sip from Qt.py --- pyqtgraph/GraphicsScene/GraphicsScene.py | 14 ++++---------- pyqtgraph/graphicsItems/GraphicsObject.py | 7 ++----- pyqtgraph/graphicsItems/UIGraphicsItem.py | 7 ++----- pyqtgraph/widgets/RemoteGraphicsView.py | 7 ++----- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/pyqtgraph/GraphicsScene/GraphicsScene.py b/pyqtgraph/GraphicsScene/GraphicsScene.py index 6569d57b..7e7b1daa 100644 --- a/pyqtgraph/GraphicsScene/GraphicsScene.py +++ b/pyqtgraph/GraphicsScene/GraphicsScene.py @@ -3,7 +3,7 @@ import time import weakref import warnings -from ..Qt import QtCore, QtGui, isQObjectAlive +from ..Qt import QtCore, QtGui, QT_LIB, isQObjectAlive from ..Point import Point from .. import functions as fn from .. import ptime as ptime @@ -14,15 +14,9 @@ from .. import getConfigOption getMillis = lambda: int(round(time.time() * 1000)) -if hasattr(QtCore, 'PYQT_VERSION'): - try: - try: - from PyQt5 import sip - except ImportError: - import sip - HAVE_SIP = True - except ImportError: - HAVE_SIP = False +if QT_LIB.startswith('PyQt'): + from ..Qt import sip + HAVE_SIP = True else: HAVE_SIP = False diff --git a/pyqtgraph/graphicsItems/GraphicsObject.py b/pyqtgraph/graphicsItems/GraphicsObject.py index fac8e819..d83949b7 100644 --- a/pyqtgraph/graphicsItems/GraphicsObject.py +++ b/pyqtgraph/graphicsItems/GraphicsObject.py @@ -1,9 +1,6 @@ from ..Qt import QtGui, QtCore, QT_LIB -if QT_LIB in ['PyQt4', 'PyQt5']: - try: - from PyQt5 import sip - except ImportError: - import sip +if QT_LIB.startswith('PyQt'): + from ..Qt import sip from .GraphicsItem import GraphicsItem __all__ = ['GraphicsObject'] diff --git a/pyqtgraph/graphicsItems/UIGraphicsItem.py b/pyqtgraph/graphicsItems/UIGraphicsItem.py index 07d32944..2f9a3bfe 100644 --- a/pyqtgraph/graphicsItems/UIGraphicsItem.py +++ b/pyqtgraph/graphicsItems/UIGraphicsItem.py @@ -1,11 +1,8 @@ from ..Qt import QtGui, QtCore, QT_LIB import weakref from .GraphicsObject import GraphicsObject -if QT_LIB in ['PyQt4', 'PyQt5']: - try: - from PyQt5 import sip - except ImportError: - import sip +if QT_LIB.startswith('PyQt'): + from ..Qt import sip __all__ = ['UIGraphicsItem'] class UIGraphicsItem(GraphicsObject): diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py index 877425d1..22065c50 100644 --- a/pyqtgraph/widgets/RemoteGraphicsView.py +++ b/pyqtgraph/widgets/RemoteGraphicsView.py @@ -1,9 +1,6 @@ from ..Qt import QtGui, QtCore, QT_LIB -if QT_LIB in ['PyQt4', 'PyQt5']: - try: - from PyQt5 import sip - except ImportError: - import sip +if QT_LIB.startswith('PyQt'): + from ..Qt import sip from .. import multiprocess as mp from .GraphicsView import GraphicsView from .. import CONFIG_OPTIONS