Added PySide2

This commit is contained in:
Andrew Murray 2018-08-03 23:07:19 +10:00
parent 1e56ed8c00
commit df328a89a4
4 changed files with 24 additions and 8 deletions

View File

@ -33,6 +33,8 @@ class PillowQPixmapTestCase(PillowQtTestCase):
from PyQt4.QtGui import QGuiApplication from PyQt4.QtGui import QGuiApplication
elif ImageQt.qt_version == 'side': elif ImageQt.qt_version == 'side':
from PySide.QtGui import QGuiApplication from PySide.QtGui import QGuiApplication
elif ImageQt.qt_version == 'side2':
from PySide2.QtGui import QGuiApplication
except ImportError: except ImportError:
self.skipTest('QGuiApplication not installed') self.skipTest('QGuiApplication not installed')
@ -56,6 +58,8 @@ class TestImageQt(PillowQtTestCase, PillowTestCase):
from PyQt4.QtGui import qRgb from PyQt4.QtGui import qRgb
elif ImageQt.qt_version == 'side': elif ImageQt.qt_version == 'side':
from PySide.QtGui import qRgb from PySide.QtGui import qRgb
elif ImageQt.qt_version == 'side2':
from PySide2.QtGui import qRgb
self.assertEqual(qRgb(0, 0, 0), qRgba(0, 0, 0, 255)) self.assertEqual(qRgb(0, 0, 0), qRgba(0, 0, 0, 255))

View File

@ -11,14 +11,22 @@ if ImageQt.qt_is_installed:
from PyQt5 import QtGui from PyQt5 import QtGui
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication
QT_VERSION = 5 QT_VERSION = 5
except (ImportError, RuntimeError):
try:
from PySide2 import QtGui
from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, \
QApplication
QT_VERSION = 5
except (ImportError, RuntimeError): except (ImportError, RuntimeError):
try: try:
from PyQt4 import QtGui from PyQt4 import QtGui
from PyQt4.QtGui import QWidget, QHBoxLayout, QLabel, QApplication from PyQt4.QtGui import QWidget, QHBoxLayout, QLabel, \
QApplication
QT_VERSION = 4 QT_VERSION = 4
except (ImportError, RuntimeError): except (ImportError, RuntimeError):
from PySide import QtGui from PySide import QtGui
from PySide.QtGui import QWidget, QHBoxLayout, QLabel, QApplication from PySide.QtGui import QWidget, QHBoxLayout, QLabel, \
QApplication
QT_VERSION = 4 QT_VERSION = 4

View File

@ -4,8 +4,8 @@
:py:mod:`ImageQt` Module :py:mod:`ImageQt` Module
======================== ========================
The :py:mod:`ImageQt` module contains support for creating PyQt4, PyQt5 or The :py:mod:`ImageQt` module contains support for creating PyQt4, PyQt5, PySide or
PySide QImage objects from PIL images. PySide2 QImage objects from PIL images.
.. versionadded:: 1.1.6 .. versionadded:: 1.1.6

View File

@ -23,6 +23,7 @@ import sys
qt_versions = [ qt_versions = [
['5', 'PyQt5'], ['5', 'PyQt5'],
['side2', 'PySide2'],
['4', 'PyQt4'], ['4', 'PyQt4'],
['side', 'PySide'] ['side', 'PySide']
] ]
@ -33,6 +34,9 @@ for qt_version, qt_module in qt_versions:
if qt_module == 'PyQt5': if qt_module == 'PyQt5':
from PyQt5.QtGui import QImage, qRgba, QPixmap from PyQt5.QtGui import QImage, qRgba, QPixmap
from PyQt5.QtCore import QBuffer, QIODevice from PyQt5.QtCore import QBuffer, QIODevice
elif qt_module == 'PySide2':
from PySide2.QtGui import QImage, qRgba, QPixmap
from PySide2.QtCore import QBuffer, QIODevice
elif qt_module == 'PyQt4': elif qt_module == 'PyQt4':
from PyQt4.QtGui import QImage, qRgba, QPixmap from PyQt4.QtGui import QImage, qRgba, QPixmap
from PyQt4.QtCore import QBuffer, QIODevice from PyQt4.QtCore import QBuffer, QIODevice