Only enable imread for new enough sip versions. Warn user if sip is too old

This commit is contained in:
Neil
2011-07-16 18:56:16 +02:00
parent 47fba11c98
commit 9b696cf34e
+12 -1
View File
@@ -10,6 +10,8 @@ try:
from PyQt4.QtGui import (QApplication, QMainWindow, QImage, QPixmap,
QLabel, QWidget)
from PyQt4 import QtCore, QtGui
import sip
import warnings
except ImportError:
window_manager._release('qt')
@@ -27,6 +29,7 @@ except ImportError:
app = None
class ImageLabel(QLabel):
def __init__(self, parent, arr):
QLabel.__init__(self)
@@ -77,7 +80,7 @@ class ImageWindow(QMainWindow):
self.mgr.remove_window(self)
def imread(filename, as_grey=False):
def imread_qt(filename, as_grey=False):
"""
Read an image using QT's QImage.load
"""
@@ -111,6 +114,14 @@ def imread(filename, as_grey=False):
return numpy.dot(img, transform)
return img
if sip.SIP_VERSION >= 0x040c00:
# sip.voidptr only acquired a buffer view in 4.12.0, so our imread
# doesn't work with earlier versions
imread = imread_qt
else:
warnings.warn(RuntimeWarning(
"sip version too old. QT imread disabled"))
def imshow(arr, fancy=False):
global app