Skip to content

Commit

Permalink
Added PyQt6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 10, 2021
1 parent f118a21 commit 674be4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Tests/test_imageqt.py
Expand Up @@ -14,7 +14,9 @@ def test_rgb():
# typedef QRgb
# An ARGB quadruplet on the format #AARRGGBB,
# equivalent to an unsigned int.
if ImageQt.qt_version == "side6":
if ImageQt.qt_version == "6":
from PyQt6.QtGui import qRgb
elif ImageQt.qt_version == "side6":
from PySide6.QtGui import qRgb
elif ImageQt.qt_version == "5":
from PyQt5.QtGui import qRgb
Expand Down
4 changes: 3 additions & 1 deletion Tests/test_qt_image_qapplication.py
Expand Up @@ -7,7 +7,9 @@
if ImageQt.qt_is_installed:
from PIL.ImageQt import QPixmap

if ImageQt.qt_version == "side6":
if ImageQt.qt_version == "6":
from PyQt6.QtWidgets import QApplication, QHBoxLayout, QLabel, QWidget
elif ImageQt.qt_version == "side6":
from PySide6.QtWidgets import QApplication, QHBoxLayout, QLabel, QWidget
elif ImageQt.qt_version == "5":
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QLabel, QWidget
Expand Down
8 changes: 7 additions & 1 deletion src/PIL/ImageQt.py
Expand Up @@ -23,6 +23,7 @@
from ._util import isPath

qt_versions = [
["6", "PyQt6"],
["side6", "PySide6"],
["5", "PyQt5"],
["side2", "PySide2"],
Expand All @@ -32,7 +33,12 @@
qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)
for qt_version, qt_module in qt_versions:
try:
if qt_module == "PySide6":
if qt_module == "PyQt6":
from PyQt6.QtCore import QBuffer
from PyQt6.QtCore.QIODevice import OpenMode as QIODevice
from PyQt6.QtGui import QPixmap, qRgba
from PyQt6.QtGui.QImage import Format as QImage
elif qt_module == "PySide6":
from PySide6.QtCore import QBuffer, QIODevice
from PySide6.QtGui import QImage, QPixmap, qRgba
elif qt_module == "PyQt5":
Expand Down

0 comments on commit 674be4e

Please sign in to comment.