##// END OF EJS Templates
Smarter Qt binding selection when environment variable is not specified.
epatters -
Show More
@@ -7,10 +7,7 b' import os'
7 7 QT_API_PYQT = 'pyqt'
8 8 QT_API_PYSIDE = 'pyside'
9 9
10 # Use PyQt by default until PySide is stable.
11 QT_API = os.environ.get('QT_API', QT_API_PYQT)
12
13 if QT_API == QT_API_PYQT:
10 def prepare_pyqt4():
14 11 # For PySide compatibility, use the new-style string API that automatically
15 12 # converts QStrings to Unicode Python strings. Also, automatically unpack
16 13 # QVariants to their underlying objects.
@@ -18,6 +15,26 b' if QT_API == QT_API_PYQT:'
18 15 sip.setapi('QString', 2)
19 16 sip.setapi('QVariant', 2)
20 17
18 # Select Qt binding, using the QT_API environment variable if available.
19 QT_API = os.environ.get('QT_API')
20 if QT_API is None:
21 try:
22 import PySide
23 QT_API = QT_API_PYSIDE
24 except ImportError:
25 try:
26 prepare_pyqt4()
27 import PyQt4
28 QT_API = QT_API_PYQT
29 except ImportError:
30 raise ImportError('Cannot import PySide or PyQt4')
31
32 elif QT_API == QT_API_PYQT:
33 # Note: This must be called *before* PyQt4 is imported.
34 prepare_pyqt4()
35
36 # Now peform the imports.
37 if QT_API == QT_API_PYQT:
21 38 from PyQt4 import QtCore, QtGui, QtSvg
22 39
23 40 # Alias PyQt-specific functions for PySide compatibility.
General Comments 0
You need to be logged in to leave comments. Login now