mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-07-21 04:01:07 +02:00
Use qtpy, deprecate superqt.qtcompat, drop support for Qt <5.12 (#39)
* remove qtcompat * change imports * change codecov * add dep * run tests against dalthviz branch * update * more replace * pin pyside6 for sake of test * add deprecation * drop qt 5.11 * unpin pyside6
This commit is contained in:
6
.github/workflows/test_and_deploy.yml
vendored
6
.github/workflows/test_and_deploy.yml
vendored
@@ -75,12 +75,6 @@ jobs:
|
||||
backend: pyqt5
|
||||
|
||||
# legacy Qt
|
||||
- python-version: 3.7
|
||||
platform: ubuntu-latest
|
||||
backend: pyside511
|
||||
- python-version: 3.7
|
||||
platform: ubuntu-latest
|
||||
backend: pyqt511
|
||||
- python-version: 3.7
|
||||
platform: ubuntu-latest
|
||||
backend: pyqt512
|
||||
|
@@ -31,8 +31,6 @@ All widgets must be well-tested, and should work on:
|
||||
- PySide2 (5.11 and above) & PySide6
|
||||
- macOS, Windows, & Linux
|
||||
|
||||
Until [qtpy](https://github.com/spyder-ide/qtpy) supports PyQt6/PySide6, imports
|
||||
should use (and modify if necessary) `superqt.qtcompat`.
|
||||
|
||||
## Style Guide
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
ignore:
|
||||
- superqt/_version.py
|
||||
- superqt/qtcompat/*
|
||||
- '*_tests*'
|
||||
coverage:
|
||||
status:
|
||||
|
@@ -16,7 +16,7 @@ an instance of
|
||||
To block and wait for the result, see [Synchronous mode](#synchronous-mode)
|
||||
|
||||
```python
|
||||
from superqt.qtcompat.QtCore import QObject
|
||||
from qtpy.QtCore import QObject
|
||||
from superqt import ensure_main_thread, ensure_object_thread
|
||||
|
||||
@ensure_main_thread
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from superqt import QRangeSlider
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.qtcompat.QtWidgets import QApplication
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from superqt import QDoubleSlider
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.qtcompat.QtWidgets import QApplication
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
"""Example for QCollapsible"""
|
||||
from qtpy.QtWidgets import QApplication, QLabel, QPushButton
|
||||
|
||||
from superqt import QCollapsible
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QLabel, QPushButton
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy import QtCore
|
||||
from qtpy import QtWidgets as QtW
|
||||
|
||||
from superqt import QRangeSlider
|
||||
from superqt.qtcompat import QtCore
|
||||
from superqt.qtcompat import QtWidgets as QtW
|
||||
|
||||
QSS = """
|
||||
QSlider {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from superqt import QElidingLabel
|
||||
from superqt.qtcompat.QtWidgets import QApplication
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
|
||||
|
||||
from superqt import QDoubleRangeSlider, QDoubleSlider, QRangeSlider
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QVBoxLayout, QWidget
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -6,9 +6,10 @@ except ImportError as e:
|
||||
"pip install git+https://github.com/tlambert03/fonticon-fontawesome5.git"
|
||||
)
|
||||
|
||||
from qtpy.QtCore import QSize
|
||||
from qtpy.QtWidgets import QApplication, QPushButton
|
||||
|
||||
from superqt.fonticon import icon, pulse
|
||||
from superqt.qtcompat.QtCore import QSize
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QPushButton
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -6,8 +6,9 @@ except ImportError as e:
|
||||
"pip install git+https://github.com/tlambert03/fonticon-fontawesome5.git"
|
||||
)
|
||||
|
||||
from qtpy.QtWidgets import QApplication, QPushButton
|
||||
|
||||
from superqt.fonticon import setTextIcon
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QPushButton
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -6,9 +6,10 @@ except ImportError as e:
|
||||
"pip install git+https://github.com/tlambert03/fonticon-fontawesome5.git"
|
||||
)
|
||||
|
||||
from qtpy.QtCore import QSize
|
||||
from qtpy.QtWidgets import QApplication, QPushButton
|
||||
|
||||
from superqt.fonticon import IconOpts, icon, pulse, spin
|
||||
from superqt.qtcompat.QtCore import QSize
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QPushButton
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from superqt import QDoubleSlider
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.qtcompat.QtWidgets import QApplication
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from qtpy import QtCore, QtGui, QtWidgets
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from superqt.fonticon._plugins import loaded
|
||||
from superqt.qtcompat import QtCore, QtGui, QtWidgets
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
|
||||
P = loaded(load_all=True)
|
||||
if not P:
|
||||
|
@@ -1,11 +1,12 @@
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidget
|
||||
|
||||
from superqt import (
|
||||
QLabeledDoubleRangeSlider,
|
||||
QLabeledDoubleSlider,
|
||||
QLabeledRangeSlider,
|
||||
QLabeledSlider,
|
||||
)
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.qtcompat.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidget
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from superqt import QRangeSlider
|
||||
from superqt.qtcompat.QtWidgets import QApplication
|
||||
|
||||
app = QApplication([])
|
||||
|
||||
|
@@ -35,6 +35,7 @@ project_urls =
|
||||
[options]
|
||||
packages = find:
|
||||
install_requires =
|
||||
qtpy
|
||||
typing-extensions>=3.10.0.0
|
||||
python_requires = >=3.7
|
||||
include_package_data = True
|
||||
@@ -86,11 +87,6 @@ superqt = py.typed
|
||||
exclude = _version.py,.eggs,examples
|
||||
docstring-convention = numpy
|
||||
ignore = E203,W503,E501,C901,F403,F405,D100
|
||||
per-file-ignores =
|
||||
src/superqt/qtcompat/QtCore.py:F401
|
||||
src/superqt/qtcompat/QtGui.py:F401
|
||||
src/superqt/qtcompat/QtWidgets.py:F401
|
||||
src/superqt/qtcompat/__init__.py:F401,F811
|
||||
|
||||
[pydocstyle]
|
||||
convention = numpy
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from typing import List
|
||||
|
||||
from superqt.qtcompat.QtCore import QPoint, QRect, QSize, Qt
|
||||
from superqt.qtcompat.QtGui import QFont, QFontMetrics, QResizeEvent, QTextLayout
|
||||
from superqt.qtcompat.QtWidgets import QLabel
|
||||
from qtpy.QtCore import QPoint, QRect, QSize, Qt
|
||||
from qtpy.QtGui import QFont, QFontMetrics, QResizeEvent, QTextLayout
|
||||
from qtpy.QtWidgets import QLabel
|
||||
|
||||
|
||||
class QElidingLabel(QLabel):
|
||||
|
@@ -1,14 +1,14 @@
|
||||
"""A collapsible widget to hide and unhide child widgets"""
|
||||
from typing import Optional
|
||||
|
||||
from ..qtcompat.QtCore import (
|
||||
from qtpy.QtCore import (
|
||||
QAbstractAnimation,
|
||||
QEasingCurve,
|
||||
QMargins,
|
||||
QPropertyAnimation,
|
||||
Qt,
|
||||
)
|
||||
from ..qtcompat.QtWidgets import QFrame, QPushButton, QVBoxLayout, QWidget
|
||||
from qtpy.QtWidgets import QFrame, QPushButton, QVBoxLayout, QWidget
|
||||
|
||||
|
||||
class QCollapsible(QFrame):
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from enum import Enum, EnumMeta
|
||||
from typing import Optional, TypeVar
|
||||
|
||||
from ..qtcompat.QtCore import Signal
|
||||
from ..qtcompat.QtWidgets import QComboBox
|
||||
from qtpy.QtCore import Signal
|
||||
from qtpy.QtWidgets import QComboBox
|
||||
|
||||
EnumType = TypeVar("EnumType", bound=Enum)
|
||||
|
||||
|
@@ -22,8 +22,8 @@ from ._qfont_icon import DEFAULT_SCALING_FACTOR, IconOptionDict, IconOpts
|
||||
from ._qfont_icon import QFontIconStore as _QFIS
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from superqt.qtcompat.QtGui import QFont, QTransform
|
||||
from superqt.qtcompat.QtWidgets import QWidget
|
||||
from qtpy.QtGui import QFont, QTransform
|
||||
from qtpy.QtWidgets import QWidget
|
||||
|
||||
from ._qfont_icon import QFontIcon, ValidColor
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from superqt.qtcompat.QtCore import QRectF, QTimer
|
||||
from superqt.qtcompat.QtGui import QPainter
|
||||
from superqt.qtcompat.QtWidgets import QWidget
|
||||
from qtpy.QtCore import QRectF, QTimer
|
||||
from qtpy.QtGui import QPainter
|
||||
from qtpy.QtWidgets import QWidget
|
||||
|
||||
|
||||
class Animation(ABC):
|
||||
|
@@ -6,11 +6,9 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import DefaultDict, Dict, Optional, Sequence, Tuple, Type, Union, cast
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from ..qtcompat import QT_VERSION
|
||||
from ..qtcompat.QtCore import QObject, QPoint, QRect, QSize, Qt
|
||||
from ..qtcompat.QtGui import (
|
||||
from qtpy import QT_VERSION
|
||||
from qtpy.QtCore import QObject, QPoint, QRect, QSize, Qt
|
||||
from qtpy.QtGui import (
|
||||
QColor,
|
||||
QFont,
|
||||
QFontDatabase,
|
||||
@@ -22,7 +20,9 @@ from ..qtcompat.QtGui import (
|
||||
QPixmapCache,
|
||||
QTransform,
|
||||
)
|
||||
from ..qtcompat.QtWidgets import QApplication, QStyleOption, QWidget
|
||||
from qtpy.QtWidgets import QApplication, QStyleOption, QWidget
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from ..utils import QMessageHandler
|
||||
from ._animations import Animation
|
||||
|
||||
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DAnimation import *
|
||||
from PyQt6.Qt3DAnimation import *
|
||||
from PySide2.Qt3DAnimation import *
|
||||
from PySide6.Qt3DAnimation import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DCore import *
|
||||
from PyQt6.Qt3DCore import *
|
||||
from PySide2.Qt3DCore import *
|
||||
from PySide6.Qt3DCore import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DExtras import *
|
||||
from PyQt6.Qt3DExtras import *
|
||||
from PySide2.Qt3DExtras import *
|
||||
from PySide6.Qt3DExtras import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DInput import *
|
||||
from PyQt6.Qt3DInput import *
|
||||
from PySide2.Qt3DInput import *
|
||||
from PySide6.Qt3DInput import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DLogic import *
|
||||
from PyQt6.Qt3DLogic import *
|
||||
from PySide2.Qt3DLogic import *
|
||||
from PySide6.Qt3DLogic import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.Qt3DRender import *
|
||||
from PyQt6.Qt3DRender import *
|
||||
from PySide2.Qt3DRender import *
|
||||
from PySide6.Qt3DRender import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtCharts import *
|
||||
from PyQt6.QtCharts import *
|
||||
from PySide2.QtCharts import *
|
||||
from PySide6.QtCharts import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtConcurrent import *
|
||||
from PyQt6.QtConcurrent import *
|
||||
from PySide2.QtConcurrent import *
|
||||
from PySide6.QtConcurrent import *
|
@@ -1,12 +0,0 @@
|
||||
# type: ignore
|
||||
from . import API_NAME, _get_qtmodule
|
||||
|
||||
_QtCore = _get_qtmodule(__name__)
|
||||
globals().update(_QtCore.__dict__)
|
||||
|
||||
if "PyQt" in API_NAME:
|
||||
Property = _QtCore.pyqtProperty
|
||||
Signal = _QtCore.pyqtSignal
|
||||
SignalInstance = getattr(_QtCore, "pyqtBoundSignal", None)
|
||||
Slot = _QtCore.pyqtSlot
|
||||
__version__ = _QtCore.QT_VERSION_STR
|
@@ -1,10 +0,0 @@
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt6.QtCore import *
|
||||
from PySide2.QtCore import *
|
||||
from PySide6.QtCore import *
|
||||
|
||||
Property = pyqtProperty
|
||||
Signal = pyqtSignal
|
||||
SignalInstance = pyqtBoundSignal
|
||||
Slot = pyqtSlot
|
||||
__version__: str
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtDataVisualization import *
|
||||
from PyQt6.QtDataVisualization import *
|
||||
from PySide2.QtDataVisualization import *
|
||||
from PySide6.QtDataVisualization import *
|
@@ -1,13 +0,0 @@
|
||||
# type: ignore
|
||||
from . import API_NAME, _get_qtmodule
|
||||
|
||||
_QtGui = _get_qtmodule(__name__)
|
||||
globals().update(_QtGui.__dict__)
|
||||
|
||||
if "6" in API_NAME:
|
||||
|
||||
def pos(self, *a):
|
||||
_pos = self.position(*a)
|
||||
return _pos.toPoint()
|
||||
|
||||
_QtGui.QMouseEvent.pos = pos
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt6.QtGui import *
|
||||
from PySide2.QtGui import *
|
||||
from PySide6.QtGui import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtHelp import *
|
||||
from PyQt6.QtHelp import *
|
||||
from PySide2.QtHelp import *
|
||||
from PySide6.QtHelp import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtLocation import *
|
||||
from PyQt6.QtLocation import *
|
||||
from PySide2.QtLocation import *
|
||||
from PySide6.QtLocation import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtMacExtras import *
|
||||
from PyQt6.QtMacExtras import *
|
||||
from PySide2.QtMacExtras import *
|
||||
from PySide6.QtMacExtras import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtMultimedia import *
|
||||
from PyQt6.QtMultimedia import *
|
||||
from PySide2.QtMultimedia import *
|
||||
from PySide6.QtMultimedia import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtMultimediaWidgets import *
|
||||
from PyQt6.QtMultimediaWidgets import *
|
||||
from PySide2.QtMultimediaWidgets import *
|
||||
from PySide6.QtMultimediaWidgets import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtNetwork import *
|
||||
from PyQt6.QtNetwork import *
|
||||
from PySide2.QtNetwork import *
|
||||
from PySide6.QtNetwork import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtOpenGL import *
|
||||
from PyQt6.QtOpenGL import *
|
||||
from PySide2.QtOpenGL import *
|
||||
from PySide6.QtOpenGL import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtOpenGLFunctions import *
|
||||
from PyQt6.QtOpenGLFunctions import *
|
||||
from PySide2.QtOpenGLFunctions import *
|
||||
from PySide6.QtOpenGLFunctions import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtPositioning import *
|
||||
from PyQt6.QtPositioning import *
|
||||
from PySide2.QtPositioning import *
|
||||
from PySide6.QtPositioning import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtPrintSupport import *
|
||||
from PyQt6.QtPrintSupport import *
|
||||
from PySide2.QtPrintSupport import *
|
||||
from PySide6.QtPrintSupport import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtQml import *
|
||||
from PyQt6.QtQml import *
|
||||
from PySide2.QtQml import *
|
||||
from PySide6.QtQml import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtQuick import *
|
||||
from PyQt6.QtQuick import *
|
||||
from PySide2.QtQuick import *
|
||||
from PySide6.QtQuick import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtQuickControls2 import *
|
||||
from PyQt6.QtQuickControls2 import *
|
||||
from PySide2.QtQuickControls2 import *
|
||||
from PySide6.QtQuickControls2 import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtQuickWidgets import *
|
||||
from PyQt6.QtQuickWidgets import *
|
||||
from PySide2.QtQuickWidgets import *
|
||||
from PySide6.QtQuickWidgets import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtRemoteObjects import *
|
||||
from PyQt6.QtRemoteObjects import *
|
||||
from PySide2.QtRemoteObjects import *
|
||||
from PySide6.QtRemoteObjects import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtScript import *
|
||||
from PyQt6.QtScript import *
|
||||
from PySide2.QtScript import *
|
||||
from PySide6.QtScript import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtScriptTools import *
|
||||
from PyQt6.QtScriptTools import *
|
||||
from PySide2.QtScriptTools import *
|
||||
from PySide6.QtScriptTools import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtScxml import *
|
||||
from PyQt6.QtScxml import *
|
||||
from PySide2.QtScxml import *
|
||||
from PySide6.QtScxml import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtSensors import *
|
||||
from PyQt6.QtSensors import *
|
||||
from PySide2.QtSensors import *
|
||||
from PySide6.QtSensors import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtSerialPort import *
|
||||
from PyQt6.QtSerialPort import *
|
||||
from PySide2.QtSerialPort import *
|
||||
from PySide6.QtSerialPort import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtSql import *
|
||||
from PyQt6.QtSql import *
|
||||
from PySide2.QtSql import *
|
||||
from PySide6.QtSql import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtSvg import *
|
||||
from PyQt6.QtSvg import *
|
||||
from PySide2.QtSvg import *
|
||||
from PySide6.QtSvg import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtTest import *
|
||||
from PyQt6.QtTest import *
|
||||
from PySide2.QtTest import *
|
||||
from PySide6.QtTest import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtTextToSpeech import *
|
||||
from PyQt6.QtTextToSpeech import *
|
||||
from PySide2.QtTextToSpeech import *
|
||||
from PySide6.QtTextToSpeech import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtUiTools import *
|
||||
from PyQt6.QtUiTools import *
|
||||
from PySide2.QtUiTools import *
|
||||
from PySide6.QtUiTools import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtWebChannel import *
|
||||
from PyQt6.QtWebChannel import *
|
||||
from PySide2.QtWebChannel import *
|
||||
from PySide6.QtWebChannel import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtWebEngine import *
|
||||
from PyQt6.QtWebEngine import *
|
||||
from PySide2.QtWebEngine import *
|
||||
from PySide6.QtWebEngine import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtWebEngineCore import *
|
||||
from PyQt6.QtWebEngineCore import *
|
||||
from PySide2.QtWebEngineCore import *
|
||||
from PySide6.QtWebEngineCore import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtWebEngineWidgets import *
|
||||
from PyQt6.QtWebEngineWidgets import *
|
||||
from PySide2.QtWebEngineWidgets import *
|
||||
from PySide6.QtWebEngineWidgets import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtWebSockets import *
|
||||
from PyQt6.QtWebSockets import *
|
||||
from PySide2.QtWebSockets import *
|
||||
from PySide6.QtWebSockets import *
|
@@ -1,16 +0,0 @@
|
||||
# type: ignore
|
||||
from . import API_NAME, _get_qtmodule
|
||||
|
||||
_QtWidgets = _get_qtmodule(__name__)
|
||||
globals().update(_QtWidgets.__dict__)
|
||||
|
||||
|
||||
QApplication = _QtWidgets.QApplication
|
||||
if not hasattr(QApplication, "exec"):
|
||||
QApplication.exec = _QtWidgets.QApplication.exec_
|
||||
|
||||
# backwargs compat with qt5
|
||||
if "6" in API_NAME:
|
||||
_QtGui = _get_qtmodule("QtGui")
|
||||
QAction = _QtGui.QAction
|
||||
QShortcut = _QtGui.QShortcut
|
@@ -1,12 +0,0 @@
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt6.QtWidgets import *
|
||||
from PySide2.QtWidgets import *
|
||||
from PySide6.QtWidgets import *
|
||||
|
||||
QApplication.exec_ = QApplication.exec
|
||||
|
||||
from PyQt6 import QtGui
|
||||
from PySide6 import QtGui
|
||||
|
||||
QAction = QtGui.QAction
|
||||
QShortcut = QtGui.QShortcut
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtXml import *
|
||||
from PyQt6.QtXml import *
|
||||
from PySide2.QtXml import *
|
||||
from PySide6.QtXml import *
|
@@ -1,4 +0,0 @@
|
||||
from PyQt5.QtXmlPatterns import *
|
||||
from PyQt6.QtXmlPatterns import *
|
||||
from PySide2.QtXmlPatterns import *
|
||||
from PySide6.QtXmlPatterns import *
|
@@ -1,114 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
from importlib import abc, import_module, util
|
||||
from typing import TYPE_CHECKING, Optional, Sequence, Union
|
||||
from importlib import abc, util
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from importlib.machinery import ModuleSpec
|
||||
from types import ModuleType
|
||||
from qtpy import * # noqa
|
||||
|
||||
warnings.warn(
|
||||
"The superqt.qtcompat module is deprecated as of v0.3.0. "
|
||||
"Please import from `qtpy` instead."
|
||||
)
|
||||
|
||||
|
||||
class QtMissingError(ImportError):
|
||||
"""Error raise if no bindings could be selected."""
|
||||
|
||||
|
||||
VALID_APIS = {
|
||||
"pyqt5": "PyQt5",
|
||||
"pyqt6": "PyQt6",
|
||||
"pyside2": "PySide2",
|
||||
"pyside6": "PySide6",
|
||||
}
|
||||
|
||||
# Detecting if a binding was specified by the user
|
||||
_requested_api = os.getenv("QT_API", "").lower()
|
||||
_forced_api = os.getenv("FORCE_QT_API")
|
||||
|
||||
# warn if an invalid API has been requested
|
||||
if _requested_api and _requested_api not in VALID_APIS:
|
||||
warnings.warn(
|
||||
f"invalid QT_API specified: {_requested_api}. "
|
||||
f"Valid values include {set(VALID_APIS)}"
|
||||
)
|
||||
_forced_api = None
|
||||
_requested_api = ""
|
||||
|
||||
# TODO: FORCE_QT_API requires also using QT_API ... does that make sense?
|
||||
|
||||
# now we'll try to import QtCore
|
||||
_QtCore: Optional[ModuleType] = None
|
||||
|
||||
# If `FORCE_QT_API` is not set, we first look for previously imported bindings
|
||||
if not _forced_api:
|
||||
for api_name, module_name in VALID_APIS.items():
|
||||
if module_name in sys.modules:
|
||||
_QtCore = import_module(f"{module_name}.QtCore")
|
||||
break
|
||||
|
||||
if _QtCore is None:
|
||||
# try the requested API first, and if _forced_api is True,
|
||||
# raise an ImportError if it doesn't work.
|
||||
# Otherwise go through the list of Valid APIs until something imports
|
||||
requested = VALID_APIS.get(_requested_api)
|
||||
for module_name in sorted(VALID_APIS.values(), key=lambda x: x != requested):
|
||||
try:
|
||||
_QtCore = import_module(f"{module_name}.QtCore")
|
||||
break
|
||||
except ImportError:
|
||||
if _forced_api:
|
||||
ImportError(
|
||||
"FORCE_QT_API set and unable to import requested QT_API: {e}"
|
||||
)
|
||||
|
||||
# didn't find one... not going to work
|
||||
if _QtCore is None:
|
||||
raise QtMissingError(f"No QtCore could be found. Tried: {VALID_APIS.values()}")
|
||||
|
||||
# load variables based on what we found.
|
||||
if not _QtCore.__package__:
|
||||
raise RuntimeError("QtCore does not declare __package__?")
|
||||
|
||||
API_NAME = _QtCore.__package__
|
||||
PYSIDE2 = API_NAME == "PySide2"
|
||||
PYSIDE6 = API_NAME == "PySide6"
|
||||
PYQT5 = API_NAME == "PyQt5"
|
||||
PYQT6 = API_NAME == "PyQt6"
|
||||
QT_VERSION = getattr(_QtCore, "QT_VERSION_STR", "") or getattr(_QtCore, "__version__")
|
||||
|
||||
# lastly, emit a warning if we ended up with an API other than the one requested
|
||||
if _requested_api and API_NAME != VALID_APIS[_requested_api]:
|
||||
warnings.warn(
|
||||
f"Selected binding {_requested_api!r} could not be found, using {API_NAME!r}"
|
||||
)
|
||||
|
||||
|
||||
# Setup the meta path finder that lets us import anything using `superqt.qtcompat.Mod`
|
||||
# forward any requests for superqt.qtcompat.* to qtpy.*
|
||||
class SuperQtImporter(abc.MetaPathFinder):
|
||||
def find_spec(
|
||||
self,
|
||||
fullname: str,
|
||||
path: Optional[Sequence[Union[bytes, str]]],
|
||||
target: Optional[ModuleType] = None,
|
||||
) -> Optional[ModuleSpec]:
|
||||
"""Find a spec for the specified module.
|
||||
|
||||
If fullname is superqt.X or superqt.qtcompat.Xx ...
|
||||
it will look for API_NAME.X instead...
|
||||
|
||||
See https://docs.python.org/3/reference/import.html#the-meta-path
|
||||
"""
|
||||
def find_spec(self, fullname: str, path, target=None): # type: ignore
|
||||
if fullname.startswith(__name__):
|
||||
spec = fullname.replace(__name__, API_NAME)
|
||||
return util.find_spec(spec)
|
||||
return None
|
||||
|
||||
|
||||
def _get_qtmodule(mod_name: str) -> ModuleType:
|
||||
"""Convenience to get a submodule from the current QT_API"""
|
||||
_mod_name = mod_name.rsplit(".", maxsplit=1)[-1]
|
||||
return import_module(f"{API_NAME}.{_mod_name}")
|
||||
return util.find_spec(fullname.replace(__name__, "qtpy"))
|
||||
|
||||
|
||||
sys.meta_path.append(SuperQtImporter())
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from superqt.qtcompat.QtWidgets import QSlider
|
||||
from qtpy.QtWidgets import QSlider
|
||||
|
||||
from ._generic_range_slider import _GenericRangeSlider
|
||||
from ._generic_slider import _GenericSlider
|
||||
|
@@ -1,17 +1,9 @@
|
||||
from typing import Generic, List, Sequence, Tuple, TypeVar, Union
|
||||
|
||||
from ..qtcompat import QtGui
|
||||
from ..qtcompat.QtCore import (
|
||||
Property,
|
||||
QEvent,
|
||||
QPoint,
|
||||
QPointF,
|
||||
QRect,
|
||||
QRectF,
|
||||
Qt,
|
||||
Signal,
|
||||
)
|
||||
from ..qtcompat.QtWidgets import QSlider, QStyle, QStyleOptionSlider, QStylePainter
|
||||
from qtpy import QtGui
|
||||
from qtpy.QtCore import Property, QEvent, QPoint, QPointF, QRect, QRectF, Qt, Signal
|
||||
from qtpy.QtWidgets import QSlider, QStyle, QStyleOptionSlider, QStylePainter
|
||||
|
||||
from ._generic_slider import CC_SLIDER, SC_GROOVE, SC_HANDLE, SC_NONE, _GenericSlider
|
||||
from ._range_style import RangeSliderStyle, update_styles_from_stylesheet
|
||||
|
||||
|
@@ -22,9 +22,9 @@ QRangeSlider.
|
||||
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from ..qtcompat import QtGui
|
||||
from ..qtcompat.QtCore import QEvent, QPoint, QPointF, QRect, Qt, Signal
|
||||
from ..qtcompat.QtWidgets import (
|
||||
from qtpy import QtGui
|
||||
from qtpy.QtCore import QEvent, QPoint, QPointF, QRect, Qt, Signal
|
||||
from qtpy.QtWidgets import (
|
||||
QApplication,
|
||||
QSlider,
|
||||
QStyle,
|
||||
|
@@ -2,9 +2,9 @@ from enum import IntEnum
|
||||
from functools import partial
|
||||
from typing import Any
|
||||
|
||||
from ..qtcompat.QtCore import QPoint, QSize, Qt, Signal
|
||||
from ..qtcompat.QtGui import QFontMetrics, QValidator
|
||||
from ..qtcompat.QtWidgets import (
|
||||
from qtpy.QtCore import QPoint, QSize, Qt, Signal
|
||||
from qtpy.QtGui import QFontMetrics, QValidator
|
||||
from qtpy.QtWidgets import (
|
||||
QAbstractSlider,
|
||||
QApplication,
|
||||
QDoubleSpinBox,
|
||||
@@ -16,6 +16,7 @@ from ..qtcompat.QtWidgets import (
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ._sliders import QDoubleRangeSlider, QDoubleSlider, QRangeSlider
|
||||
|
||||
|
||||
|
@@ -5,9 +5,9 @@ import re
|
||||
from dataclasses import dataclass, replace
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..qtcompat import QT_VERSION
|
||||
from ..qtcompat.QtCore import Qt
|
||||
from ..qtcompat.QtGui import (
|
||||
from qtpy import QT_VERSION
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtGui import (
|
||||
QBrush,
|
||||
QColor,
|
||||
QGradient,
|
||||
@@ -15,7 +15,7 @@ from ..qtcompat.QtGui import (
|
||||
QPalette,
|
||||
QRadialGradient,
|
||||
)
|
||||
from ..qtcompat.QtWidgets import QApplication, QSlider, QStyleOptionSlider
|
||||
from qtpy.QtWidgets import QApplication, QSlider, QStyleOptionSlider
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._generic_range_slider import _GenericRangeSlider
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from ..qtcompat.QtCore import Signal
|
||||
from qtpy.QtCore import Signal
|
||||
|
||||
from ._generic_range_slider import _GenericRangeSlider
|
||||
from ._generic_slider import _GenericSlider
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from enum import Enum
|
||||
|
||||
from ..qtcompat.QtCore import QSize, Qt, Signal
|
||||
from ..qtcompat.QtGui import QFontMetrics, QValidator
|
||||
from ..qtcompat.QtWidgets import QAbstractSpinBox, QStyle, QStyleOptionSpinBox
|
||||
from qtpy.QtCore import QSize, Qt, Signal
|
||||
from qtpy.QtGui import QFontMetrics, QValidator
|
||||
from qtpy.QtWidgets import QAbstractSpinBox, QStyle, QStyleOptionSpinBox
|
||||
|
||||
|
||||
class _EmitPolicy(Enum):
|
||||
|
@@ -3,7 +3,7 @@ from concurrent.futures import Future
|
||||
from functools import wraps
|
||||
from typing import Callable, List, Optional
|
||||
|
||||
from superqt.qtcompat.QtCore import (
|
||||
from qtpy.QtCore import (
|
||||
QCoreApplication,
|
||||
QMetaObject,
|
||||
QObject,
|
||||
|
@@ -2,11 +2,7 @@ import logging
|
||||
from contextlib import suppress
|
||||
from typing import List, NamedTuple, Optional
|
||||
|
||||
from superqt.qtcompat.QtCore import (
|
||||
QMessageLogContext,
|
||||
QtMsgType,
|
||||
qInstallMessageHandler,
|
||||
)
|
||||
from qtpy.QtCore import QMessageLogContext, QtMsgType, qInstallMessageHandler
|
||||
|
||||
|
||||
class Record(NamedTuple):
|
||||
|
@@ -20,10 +20,9 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
from qtpy.QtCore import QObject, QRunnable, QThread, QThreadPool, QTimer, Signal
|
||||
from typing_extensions import Literal, ParamSpec
|
||||
|
||||
from ..qtcompat.QtCore import QObject, QRunnable, QThread, QThreadPool, QTimer, Signal
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
@@ -1,8 +1,9 @@
|
||||
"""A test module for testing collapsible"""
|
||||
|
||||
from qtpy.QtCore import QEasingCurve
|
||||
from qtpy.QtWidgets import QPushButton
|
||||
|
||||
from superqt import QCollapsible
|
||||
from superqt.qtcompat.QtCore import QEasingCurve
|
||||
from superqt.qtcompat.QtWidgets import QPushButton
|
||||
|
||||
|
||||
def test_checked_initialization(qtbot):
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import platform
|
||||
|
||||
from qtpy.QtCore import QSize, Qt
|
||||
from qtpy.QtGui import QResizeEvent
|
||||
|
||||
from superqt import QElidingLabel
|
||||
from superqt.qtcompat.QtCore import QSize, Qt
|
||||
from superqt.qtcompat.QtGui import QResizeEvent
|
||||
|
||||
TEXT = (
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
|
||||
|
@@ -4,8 +4,8 @@ import time
|
||||
from concurrent.futures import Future, TimeoutError
|
||||
|
||||
import pytest
|
||||
from qtpy.QtCore import QCoreApplication, QObject, QThread, Signal
|
||||
|
||||
from superqt.qtcompat.QtCore import QCoreApplication, QObject, QThread, Signal
|
||||
from superqt.utils import ensure_main_thread, ensure_object_thread
|
||||
|
||||
skip_on_ci = pytest.mark.skipif(bool(os.getenv("CI")), reason="github hangs")
|
||||
|
@@ -1,11 +1,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from qtpy.QtGui import QIcon, QPixmap
|
||||
from qtpy.QtWidgets import QPushButton
|
||||
|
||||
from superqt.fonticon import icon, pulse, setTextIcon, spin
|
||||
from superqt.fonticon._qfont_icon import QFontIconStore, _ensure_identifier
|
||||
from superqt.qtcompat.QtGui import QIcon, QPixmap
|
||||
from superqt.qtcompat.QtWidgets import QPushButton
|
||||
|
||||
TEST_PREFIX = "ico"
|
||||
TEST_CHARNAME = "smiley"
|
||||
|
@@ -2,10 +2,10 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from qtpy.QtGui import QIcon, QPixmap
|
||||
|
||||
from superqt.fonticon import _plugins, icon
|
||||
from superqt.fonticon._qfont_icon import QFontIconStore
|
||||
from superqt.qtcompat.QtGui import QIcon, QPixmap
|
||||
|
||||
try:
|
||||
from importlib.metadata import Distribution
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from superqt.spinbox import QLargeIntSpinBox
|
||||
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import logging
|
||||
|
||||
from qtpy import QtCore
|
||||
|
||||
from superqt import QMessageHandler
|
||||
from superqt.qtcompat import QtCore
|
||||
|
||||
|
||||
def test_message_handler():
|
||||
|
@@ -2,10 +2,9 @@ from contextlib import suppress
|
||||
from platform import system
|
||||
|
||||
import pytest
|
||||
|
||||
from superqt.qtcompat import QT_VERSION
|
||||
from superqt.qtcompat.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from superqt.qtcompat.QtGui import QMouseEvent, QWheelEvent
|
||||
from qtpy import QT_VERSION
|
||||
from qtpy.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from qtpy.QtGui import QMouseEvent, QWheelEvent
|
||||
|
||||
QT_VERSION = tuple(int(x) for x in QT_VERSION.split("."))
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from qtpy import API_NAME
|
||||
|
||||
from superqt import (
|
||||
QDoubleRangeSlider,
|
||||
@@ -8,7 +9,6 @@ from superqt import (
|
||||
QLabeledDoubleRangeSlider,
|
||||
QLabeledDoubleSlider,
|
||||
)
|
||||
from superqt.qtcompat import API_NAME
|
||||
|
||||
range_types = {QDoubleRangeSlider, QLabeledDoubleRangeSlider}
|
||||
|
||||
|
@@ -2,10 +2,10 @@ import math
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
from qtpy.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from qtpy.QtGui import QHoverEvent
|
||||
from qtpy.QtWidgets import QStyle, QStyleOptionSlider
|
||||
|
||||
from superqt.qtcompat.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from superqt.qtcompat.QtGui import QHoverEvent
|
||||
from superqt.qtcompat.QtWidgets import QStyle, QStyleOptionSlider
|
||||
from superqt.sliders._generic_slider import _GenericSlider, _sliderValueFromPosition
|
||||
|
||||
from ._testutil import _linspace, _mouse_event, _wheel_event, skip_on_linux_qt6
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import math
|
||||
|
||||
import pytest
|
||||
from qtpy.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from qtpy.QtGui import QHoverEvent
|
||||
from qtpy.QtWidgets import QStyle, QStyleOptionSlider
|
||||
|
||||
from superqt import QDoubleRangeSlider, QRangeSlider
|
||||
from superqt.qtcompat.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from superqt.qtcompat.QtGui import QHoverEvent
|
||||
from superqt.qtcompat.QtWidgets import QStyle, QStyleOptionSlider
|
||||
|
||||
from ._testutil import _linspace, _mouse_event, _wheel_event, skip_on_linux_qt6
|
||||
|
||||
|
@@ -3,11 +3,11 @@ import platform
|
||||
from contextlib import suppress
|
||||
|
||||
import pytest
|
||||
from qtpy.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from qtpy.QtGui import QHoverEvent
|
||||
from qtpy.QtWidgets import QSlider, QStyle, QStyleOptionSlider
|
||||
|
||||
from superqt import QDoubleSlider, QLabeledDoubleSlider, QLabeledSlider
|
||||
from superqt.qtcompat.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from superqt.qtcompat.QtGui import QHoverEvent
|
||||
from superqt.qtcompat.QtWidgets import QSlider, QStyle, QStyleOptionSlider
|
||||
from superqt.sliders._generic_slider import _GenericSlider
|
||||
|
||||
from ._testutil import (
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
from qtpy import API_NAME
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from superqt import QRangeSlider
|
||||
from superqt.qtcompat import API_NAME
|
||||
from superqt.qtcompat.QtCore import Qt
|
||||
from superqt.sliders._generic_range_slider import SC_BAR, SC_HANDLE, SC_NONE
|
||||
|
||||
NOT_LINUX = platform.system() != "Linux"
|
||||
|
7
tox.ini
7
tox.ini
@@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = py{37,38,39,310}-{linux,macos,windows}-{pyqt5,pyside2,pyqt6,pyside6},py37-linux-{pyqt511,pyside511,pyqt512,pyqt513,pyqt514}
|
||||
envlist = py{37,38,39,310}-{linux,macos,windows}-{pyqt5,pyside2,pyqt6,pyside6},py37-linux-{pyqt512,pyqt513,pyqt514}
|
||||
toxworkdir=/tmp/.tox
|
||||
isolated_build=True
|
||||
|
||||
@@ -12,7 +12,6 @@ exclude_lines =
|
||||
raise NotImplementedError()
|
||||
omit =
|
||||
superqt/_version.py
|
||||
superqt/qtcompat/*
|
||||
*_tests*
|
||||
|
||||
[gh-actions]
|
||||
@@ -37,8 +36,6 @@ BACKEND =
|
||||
pyside2: pyside2
|
||||
pyqt6: pyqt6
|
||||
pyside6: pyside6
|
||||
pyside511: pyside511
|
||||
pyqt511: pyqt511
|
||||
pyqt512: pyqt512
|
||||
pyqt513: pyqt513
|
||||
pyqt514: pyqt514
|
||||
@@ -50,8 +47,6 @@ platform =
|
||||
windows: win32
|
||||
passenv = CI GITHUB_ACTIONS DISPLAY XAUTHORITY
|
||||
deps =
|
||||
pyqt511: pyqt5==5.11.*
|
||||
pyside511: pyside2==5.11.*
|
||||
pyqt512: pyqt5==5.12.*
|
||||
pyside512: pyside2==5.12.*
|
||||
pyqt513: pyqt5==5.13.*
|
||||
|
Reference in New Issue
Block a user