2012-03-02 02:55:32 +00:00
|
|
|
## Do all Qt imports from here to allow easier PyQt / PySide compatibility
|
2012-10-03 01:23:59 +00:00
|
|
|
import sys, re
|
2012-03-02 02:55:32 +00:00
|
|
|
|
2012-09-09 23:07:36 +00:00
|
|
|
## Automatically determine whether to use PyQt or PySide.
|
|
|
|
## This is done by first checking to see whether one of the libraries
|
|
|
|
## is already imported. If not, then attempt to import PyQt4, then PySide.
|
|
|
|
if 'PyQt4' in sys.modules:
|
|
|
|
USE_PYSIDE = False
|
|
|
|
elif 'PySide' in sys.modules:
|
|
|
|
USE_PYSIDE = True
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
import PyQt4
|
|
|
|
USE_PYSIDE = False
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import Pyside
|
|
|
|
USE_PYSIDE = True
|
|
|
|
except ImportError:
|
|
|
|
raise Exception("PyQtGraph requires either PyQt4 or PySide; neither package could be imported.")
|
2012-06-29 18:39:27 +00:00
|
|
|
|
|
|
|
if USE_PYSIDE:
|
|
|
|
from PySide import QtGui, QtCore, QtOpenGL, QtSvg
|
2012-06-29 19:08:14 +00:00
|
|
|
import PySide
|
2012-06-29 18:39:27 +00:00
|
|
|
VERSION_INFO = 'PySide ' + PySide.__version__
|
|
|
|
else:
|
|
|
|
from PyQt4 import QtGui, QtCore
|
|
|
|
try:
|
|
|
|
from PyQt4 import QtSvg
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
from PyQt4 import QtOpenGL
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2012-05-11 22:05:41 +00:00
|
|
|
|
2012-03-02 04:23:33 +00:00
|
|
|
QtCore.Signal = QtCore.pyqtSignal
|
2012-06-29 18:39:27 +00:00
|
|
|
VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR
|
2012-10-03 01:23:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Make sure we have Qt >= 4.7
|
|
|
|
versionReq = [4, 7]
|
|
|
|
QtVersion = PySide.QtCore.__version__ if USE_PYSIDE else QtCore.QT_VERSION_STR
|
|
|
|
m = re.match(r'(\d+)\.(\d+).*', QtVersion)
|
|
|
|
if m is not None and map(int, m.groups()) < versionReq:
|
|
|
|
print map(int, m.groups())
|
2012-10-06 06:23:23 +00:00
|
|
|
raise Exception('pyqtgraph requires Qt version >= %d.%d (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))
|
2012-10-03 01:23:59 +00:00
|
|
|
|