move Qt.py to Qt/__init__.py

This commit is contained in:
KIU Shueng Chuan 2021-06-20 20:54:59 +08:00
parent 11bf824c0a
commit 3a1b74df6f
5 changed files with 23 additions and 1 deletions

View File

@ -12,7 +12,7 @@ This module exists to smooth out some of the differences between PySide and PyQt
import os, sys, re, time, subprocess, warnings
from .python2_3 import asUnicode
from ..python2_3 import asUnicode
PYSIDE = 'PySide'
PYSIDE2 = 'PySide2'
@ -206,6 +206,28 @@ else:
raise ValueError("Invalid Qt lib '%s'" % QT_LIB)
# For historical reasons, pyqtgraph maintains a Qt4-ish interface back when
# there wasn't a QtWidgets module. This _was_ done by monkey-patching all of
# QtWidgets into the QtGui module. The next section of code mirrors the
# various symbols from QtCore, QtGui and QtWidgets into the corresponding local
# ones.
# Thus, when monkey-patching happens later on in this file, they will only affect
# the local modules and not the global modules.
def _copy_attrs(dst, src):
for o in dir(src):
if not hasattr(dst, o):
setattr(dst, o, getattr(src, o))
return dst
from .imports import QtCore as tmp
QtCore = _copy_attrs(tmp, QtCore)
from .imports import QtGui as tmp
QtGui = _copy_attrs(tmp, QtGui)
from .imports import QtWidgets as tmp
QtWidgets = _copy_attrs(tmp, QtWidgets)
del tmp
# common to PyQt5, PyQt6, PySide2 and PySide6
if QT_LIB in [PYQT5, PYQT6, PYSIDE2, PYSIDE6]:
# We're using Qt5 which has a different structure so we're going to use a shim to

View File

View File

View File