From 2f29c1233adf1f7f90798ca368cce438711edd3a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 16 Oct 2021 22:55:26 +0300 Subject: [PATCH 1/3] Test PyQt6 on MinGW --- .github/workflows/test-mingw.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-mingw.yml b/.github/workflows/test-mingw.yml index b9d2abeb3..6125af024 100644 --- a/.github/workflows/test-mingw.yml +++ b/.github/workflows/test-mingw.yml @@ -42,7 +42,7 @@ jobs: ${{ matrix.package }}-python3-numpy \ ${{ matrix.package }}-python3-olefile \ ${{ matrix.package }}-python3-pip \ - ${{ matrix.package }}-python3-pyqt5 \ + ${{ matrix.package }}-python-pyqt6 \ ${{ matrix.package }}-python3-setuptools \ ${{ matrix.package }}-freetype \ ${{ matrix.package }}-ghostscript \ From d1148378bcc671a2da5ba3101c44b822dec7ff0c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 16 Oct 2021 23:04:43 +0300 Subject: [PATCH 2/3] Fix for PyQt6 --- src/PIL/ImageQt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index 32630f2ca..6b965ffe4 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -34,7 +34,7 @@ qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=Tr for qt_version, qt_module in qt_versions: try: if qt_module == "PyQt6": - from PyQt6.QtCore import QBuffer, QIODevice + from PyQt6.QtCore import QBuffer, QIODevice, QIODeviceBase from PyQt6.QtGui import QImage, QPixmap, qRgba elif qt_module == "PySide6": from PySide6.QtCore import QBuffer, QIODevice @@ -66,7 +66,13 @@ def fromqimage(im): :param im: QImage or PIL ImageQt object """ buffer = QBuffer() - qt_openmode = QIODevice.OpenMode if qt_version == "6" else QIODevice + if qt_version == "6": + try: + qt_openmode = QIODeviceBase.OpenModeFlag + except AttributeError: + qt_openmode = QIODevice.OpenMode + else: + qt_openmode = QIODevice buffer.open(qt_openmode.ReadWrite) # preserve alpha channel with png # otherwise ppm is more friendly with Image.open From 43ceaa1614b7d81ac5b2c7483bc9bfb3126d39a4 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 17 Oct 2021 13:14:47 +1100 Subject: [PATCH 3/3] Use QIODevice instead of QIODeviceBase --- src/PIL/ImageQt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index 6b965ffe4..e142f1f27 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -34,7 +34,7 @@ qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=Tr for qt_version, qt_module in qt_versions: try: if qt_module == "PyQt6": - from PyQt6.QtCore import QBuffer, QIODevice, QIODeviceBase + from PyQt6.QtCore import QBuffer, QIODevice from PyQt6.QtGui import QImage, QPixmap, qRgba elif qt_module == "PySide6": from PySide6.QtCore import QBuffer, QIODevice @@ -68,7 +68,7 @@ def fromqimage(im): buffer = QBuffer() if qt_version == "6": try: - qt_openmode = QIODeviceBase.OpenModeFlag + qt_openmode = QIODevice.OpenModeFlag except AttributeError: qt_openmode = QIODevice.OpenMode else: