Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions qtpy/Qt3DAnimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
) from error
elif PYQT6:
try:
from PyQt6 import Qt3DAnimation
from PyQt6.Qt3DAnimation import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(Qt3DAnimation)
del Qt3DAnimation
except ModuleNotFoundError as error:
raise QtModuleNotInstalledError(
name="Qt3DAnimation",
Expand Down
7 changes: 7 additions & 0 deletions qtpy/Qt3DRender.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
) from error
elif PYQT6:
try:
from PyQt6 import Qt3DRender
from PyQt6.Qt3DRender import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(Qt3DRender)
del Qt3DRender
except ModuleNotFoundError as error:
raise QtModuleNotInstalledError(
name="Qt3DRender",
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtDBus.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
if PYQT5:
from PyQt5.QtDBus import *
elif PYQT6:
from PyQt6 import QtDBus
from PyQt6.QtDBus import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtDBus)
del QtDBus
elif PYSIDE2:
raise QtBindingMissingModuleError(name="QtDBus")
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtDesigner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
if PYQT5:
from PyQt5.QtDesigner import *
elif PYQT6:
from PyQt6 import QtDesigner
from PyQt6.QtDesigner import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtDesigner)
del QtDesigner
elif PYSIDE2:
raise QtBindingMissingModuleError(name="QtDesigner")
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtHelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtHelp import *
elif PYQT6:
from PyQt6 import QtHelp
from PyQt6.QtHelp import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtHelp)
del QtHelp
elif PYSIDE2:
from PySide2.QtHelp import *
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtMultimedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtMultimedia import *
elif PYQT6:
from PyQt6 import QtMultimedia
from PyQt6.QtMultimedia import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtMultimedia)
del QtMultimedia
elif PYSIDE2:
from PySide2.QtMultimedia import *
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
if PYQT5:
from PyQt5.QtNetwork import *
elif PYQT6:
from PyQt6 import QtNetwork
from PyQt6.QtNetwork import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtNetwork)
del QtNetwork
elif PYSIDE2:
from PySide2.QtNetwork import *
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtOpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@
from PyQt5.QtGui import QOpenGLTimeMonitor, QOpenGLTimerQuery

elif PYQT6:
from PyQt6 import QtOpenGL
from PyQt6.QtGui import QOpenGLContext, QOpenGLContextGroup
from PyQt6.QtOpenGL import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtOpenGL)
del QtOpenGL
elif PYSIDE6:
from PySide6.QtGui import QOpenGLContext, QOpenGLContextGroup
from PySide6.QtOpenGL import *
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtOpenGLWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
if PYQT5:
raise QtBindingMissingModuleError(name="QtOpenGLWidgets")
elif PYQT6:
from PyQt6 import QtOpenGLWidgets
from PyQt6.QtOpenGLWidgets import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtOpenGLWidgets)
del QtOpenGLWidgets
elif PYSIDE2:
raise QtBindingMissingModuleError(name="QtOpenGLWidgets")
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtPositioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtPositioning import *
elif PYQT6:
from PyQt6 import QtPositioning
from PyQt6.QtPositioning import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtPositioning)
del QtPositioning
elif PYSIDE2:
from PySide2.QtPositioning import *
elif PYSIDE6:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtPrintSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
if PYQT5:
from PyQt5.QtPrintSupport import *
elif PYQT6:
from PyQt6 import QtPrintSupport
from PyQt6.QtPrintSupport import *

QPageSetupDialog.exec_ = lambda self, *args, **kwargs: self.exec(
Expand All @@ -26,6 +27,12 @@
*args,
**kwargs,
)

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtPrintSupport)
del QtPrintSupport
elif PYSIDE6:
from PySide6.QtPrintSupport import *

Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtQml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtQml import *
elif PYQT6:
from PyQt6 import QtQml
from PyQt6.QtQml import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtQml)
del QtQml
elif PYSIDE6:
from PySide6.QtQml import *
elif PYSIDE2:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtQuick.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtQuick import *
elif PYQT6:
from PyQt6 import QtQuick
from PyQt6.QtQuick import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtQuick)
del QtQuick
elif PYSIDE6:
from PySide6.QtQuick import *
elif PYSIDE2:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtQuickWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtQuickWidgets import *
elif PYQT6:
from PyQt6 import QtQuickWidgets
from PyQt6.QtQuickWidgets import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtQuickWidgets)
del QtQuickWidgets
elif PYSIDE6:
from PySide6.QtQuickWidgets import *
elif PYSIDE2:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtSensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtSensors import *
elif PYQT6:
from PyQt6 import QtSensors
from PyQt6.QtSensors import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtSensors)
del QtSensors
elif PYSIDE6:
from PySide6.QtSensors import *
elif PYSIDE2:
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtSql.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
if PYQT5:
from PyQt5.QtSql import *
elif PYQT6:
from PyQt6 import QtSql
from PyQt6.QtSql import *

QSqlDatabase.exec_ = lambda self, *args, **kwargs: self.exec(
Expand All @@ -20,6 +21,12 @@
)
QSqlQuery.exec_ = lambda self, *args, **kwargs: self.exec(*args, **kwargs)
QSqlResult.exec_ = lambda self, *args, **kwargs: self.exec(*args, **kwargs)

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtSql)
del QtSql
elif PYSIDE6:
from PySide6.QtSql import *

Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtStateMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@
from PyQt6.QtCore import PYQT_VERSION_STR

if int(PYQT_VERSION_STR.split(".")[1]) >= 9:
from PyQt6 import QtStateMachine
from PyQt6.QtStateMachine import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtStateMachine)
del QtStateMachine
else:
from . import QtBindingInNewerVersionError

Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtWebEngineCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
) from error
elif PYQT6:
try:
from PyQt6 import QtWebEngineCore
from PyQt6.QtWebEngineCore import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtWebEngineCore)
del QtWebEngineCore
except ModuleNotFoundError as error:
raise QtModuleNotInstalledError(
name="QtWebEngineCore",
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtWebEngineQuick.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
raise QtBindingMissingModuleError(name="QtWebEngineQuick")
elif PYQT6:
try:
from PyQt6 import QtWebEngineQuick
from PyQt6.QtWebEngineQuick import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtWebEngineQuick)
del QtWebEngineQuick
except ModuleNotFoundError as error:
raise QtModuleNotInstalledError(
name="QtWebEngineQuick",
Expand Down
7 changes: 7 additions & 0 deletions qtpy/QtXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
if PYQT5:
from PyQt5.QtXml import *
elif PYQT6:
from PyQt6 import QtXml
from PyQt6.QtXml import *

# Allow unscoped access for enums
from .enums_compat import promote_enums

promote_enums(QtXml)
del QtXml
elif PYSIDE2:
from PySide2.QtXml import *
elif PYSIDE6:
Expand Down
18 changes: 18 additions & 0 deletions qtpy/tests/test_qtdbus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from qtpy import PYQT5, PYQT_VERSION
from qtpy.tests.utils import pytest_importorskip


Expand All @@ -11,3 +12,20 @@ def test_qtdbus():
assert QtDBus.QDBusAbstractInterface is not None
assert QtDBus.QDBusArgument is not None
assert QtDBus.QDBusConnection is not None


@pytest.mark.skipif(
PYQT5 and PYQT_VERSION.startswith("5.9"),
reason=(
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
"to work with scoped enum access"
),
)
def test_enum_access():
"""Test scoped and unscoped enum access."""
QtDBus = pytest_importorskip("qtpy.QtDBus")

assert (
QtDBus.QDBusError.InvalidSignature
== QtDBus.QDBusError.ErrorType.InvalidSignature
)
19 changes: 16 additions & 3 deletions qtpy/tests/test_qtprintsupport.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Test QtPrintSupport."""

import sys

import pytest

from qtpy import QtPrintSupport
from qtpy import PYQT5, PYQT_VERSION, QtPrintSupport


def test_qtprintsupport():
Expand Down Expand Up @@ -34,3 +32,18 @@ def test_qprintpreviewwidget_print_(qtbot):
assert QtPrintSupport.QPrintPreviewWidget.print_ is not None
preview_widget = QtPrintSupport.QPrintPreviewWidget()
preview_widget.print_()


@pytest.mark.skipif(
PYQT5 and PYQT_VERSION.startswith("5.9"),
reason=(
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
"to work with scoped enum access"
),
)
def test_enum_access():
"""Test scoped and unscoped enum access"""
assert (
QtPrintSupport.QPrinter.HighResolution
== QtPrintSupport.QPrinter.PrinterMode.HighResolution
)
Loading