import shiboken{2,6} as shiboken

This commit is contained in:
KIU Shueng Chuan 2021-07-31 15:49:56 +08:00
parent 7aa5d0cbf4
commit 9913f7c1e7
3 changed files with 15 additions and 19 deletions

View File

@ -17,12 +17,10 @@ import pyqtgraph.functions as fn
import itertools
import argparse
if QT_LIB == 'PySide2':
wrapinstance = pg.Qt.shiboken2.wrapInstance
elif QT_LIB == 'PySide6':
wrapinstance = pg.Qt.shiboken6.wrapInstance
elif QT_LIB in ['PyQt5', 'PyQt6']:
if QT_LIB.startswith('PyQt'):
wrapinstance = pg.Qt.sip.wrapinstance
else:
wrapinstance = pg.Qt.shiboken.wrapInstance
# defaults here result in the same configuration as the original PlotSpeedTest
parser = argparse.ArgumentParser()

View File

@ -152,7 +152,12 @@ if QT_LIB == PYQT5:
_copy_attrs(PyQt5.QtGui, QtGui)
_copy_attrs(PyQt5.QtWidgets, QtWidgets)
from PyQt5 import sip, uic
try:
from PyQt5 import sip
except ImportError:
# some Linux distros package it this way (e.g. Ubuntu)
import sip
from PyQt5 import uic
try:
from PyQt5 import QtSvg
@ -203,8 +208,7 @@ elif QT_LIB == PYSIDE2:
except ImportError as err:
QtTest = FailedImport(err)
import shiboken2
isQObjectAlive = shiboken2.isValid
import shiboken2 as shiboken
import PySide2
VERSION_INFO = 'PySide2 ' + PySide2.__version__ + ' Qt ' + QtCore.__version__
elif QT_LIB == PYSIDE6:
@ -226,8 +230,7 @@ elif QT_LIB == PYSIDE6:
except ImportError as err:
QtTest = FailedImport(err)
import shiboken6
isQObjectAlive = shiboken6.isValid
import shiboken6 as shiboken
import PySide6
VERSION_INFO = 'PySide6 ' + PySide6.__version__ + ' Qt ' + QtCore.__version__
@ -313,6 +316,7 @@ if QT_LIB in [PYQT6, PYSIDE6]:
if QT_LIB in [PYSIDE2, PYSIDE6]:
QtVersion = QtCore.__version__
loadUiType = _loadUiType
isQObjectAlive = shiboken.isValid
# PySide does not implement qWait
if not isinstance(QtTest, FailedImport):

View File

@ -4,6 +4,7 @@ import itertools
import math
import numpy as np
import weakref
from .. import Qt
from ..Qt import QtGui, QtCore, QT_LIB
from ..Point import Point
from .. import functions as fn
@ -13,13 +14,6 @@ from .. import getConfigOption
from collections import OrderedDict
from .. import debug
if QT_LIB == 'PySide2':
from shiboken2 import wrapInstance
elif QT_LIB == 'PySide6':
from shiboken6 import wrapInstance
elif QT_LIB in ['PyQt5', 'PyQt6']:
from ..Qt import sip
__all__ = ['ScatterPlotItem', 'SpotItem']
@ -167,11 +161,11 @@ class PixmapFragments:
# instances into a contiguous array, in order to call the underlying C++ native API.
self.arr = np.empty((size, 10), dtype=np.float64)
if QT_LIB.startswith('PyQt'):
self.ptrs = list(map(sip.wrapinstance,
self.ptrs = list(map(Qt.sip.wrapinstance,
itertools.count(self.arr.ctypes.data, self.arr.strides[0]),
itertools.repeat(QtGui.QPainter.PixmapFragment, self.arr.shape[0])))
else:
self.ptrs = wrapInstance(self.arr.ctypes.data, QtGui.QPainter.PixmapFragment)
self.ptrs = Qt.shiboken.wrapInstance(self.arr.ctypes.data, QtGui.QPainter.PixmapFragment)
def array(self, size):
if size > self.arr.shape[0]: