mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
Do not attempt to subclass QImage if Qt is not installed
This commit is contained in:
parent
b318595666
commit
fa1c4bffaf
|
@ -22,18 +22,18 @@ import sys
|
||||||
|
|
||||||
qt_is_installed = True
|
qt_is_installed = True
|
||||||
try:
|
try:
|
||||||
from PyQt5.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
from PyQt5.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
||||||
from PyQt5.QtCore import QBuffer, QIODevice
|
from PyQt5.QtCore import QBuffer, QIODevice
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from PyQt4.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
from PyQt4.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
||||||
from PyQt4.QtCore import QBuffer, QIODevice
|
from PyQt4.QtCore import QBuffer, QIODevice
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from PySide.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
from PySide.QtGui import QGuiApplication, QImage, qRgb, qRgba, QPixmap
|
||||||
from PySide.QtCore import QBuffer, QIODevice
|
from PySide.QtCore import QBuffer, QIODevice
|
||||||
except ImportError:
|
except ImportError:
|
||||||
qt_is_installed = False
|
qt_is_installed = False
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
@ -147,13 +147,14 @@ def toqpixmap(im):
|
||||||
# @param im A PIL Image object, or a file name (given either as Python
|
# @param im A PIL Image object, or a file name (given either as Python
|
||||||
# string or a PyQt string object).
|
# string or a PyQt string object).
|
||||||
|
|
||||||
class ImageQt(QImage):
|
if qt_is_installed:
|
||||||
|
class ImageQt(QImage):
|
||||||
|
|
||||||
def __init__(self, im):
|
def __init__(self, im):
|
||||||
im_data = _toqclass_helper(im)
|
im_data = _toqclass_helper(im)
|
||||||
QImage.__init__(self,
|
QImage.__init__(self,
|
||||||
im_data['data'], im_data['im'].size[0], im_data['im'].size[1],
|
im_data['data'], im_data['im'].size[0], im_data['im'].size[1],
|
||||||
im_data['format']
|
im_data['format']
|
||||||
)
|
)
|
||||||
if im_data['colortable']:
|
if im_data['colortable']:
|
||||||
self.setColorTable(im_data['colortable'])
|
self.setColorTable(im_data['colortable'])
|
Loading…
Reference in New Issue
Block a user