##// END OF EJS Templates
add '--quick' to irunner args, to prevent loading default config
add '--quick' to irunner args, to prevent loading default config

File last commit:

r4191:f9321fb2
r4213:cd98bc33
Show More
qt.py
54 lines | 1.5 KiB | text/x-python | PythonLexer
Evan Patterson
Paved the way for PySide support....
r3304 """ A Qt API selector that can be used to switch between PyQt and PySide.
MinRK
reorder qt support in kernel...
r4191
This uses the ETS 4.0 selection pattern of:
PySide first, PyQt with API v2. second.
Do not use this if you need PyQt with the old QString/QVariant API.
Evan Patterson
Paved the way for PySide support....
r3304 """
import os
epatters
Clean up in Qt API switcher.
r3306 # Available APIs.
QT_API_PYQT = 'pyqt'
QT_API_PYSIDE = 'pyside'
epatters
Smarter Qt binding selection when environment variable is not specified.
r3927 def prepare_pyqt4():
epatters
Fixed PySide incompatibility with QVariant....
r3364 # For PySide compatibility, use the new-style string API that automatically
# converts QStrings to Unicode Python strings. Also, automatically unpack
# QVariants to their underlying objects.
Evan Patterson
Paved the way for PySide support....
r3304 import sip
sip.setapi('QString', 2)
epatters
Fixed PySide incompatibility with QVariant....
r3364 sip.setapi('QVariant', 2)
Evan Patterson
Paved the way for PySide support....
r3304
epatters
Smarter Qt binding selection when environment variable is not specified.
r3927 # Select Qt binding, using the QT_API environment variable if available.
QT_API = os.environ.get('QT_API')
if QT_API is None:
try:
import PySide
QT_API = QT_API_PYSIDE
except ImportError:
try:
prepare_pyqt4()
import PyQt4
QT_API = QT_API_PYQT
except ImportError:
raise ImportError('Cannot import PySide or PyQt4')
elif QT_API == QT_API_PYQT:
# Note: This must be called *before* PyQt4 is imported.
prepare_pyqt4()
# Now peform the imports.
if QT_API == QT_API_PYQT:
Evan Patterson
Paved the way for PySide support....
r3304 from PyQt4 import QtCore, QtGui, QtSvg
# Alias PyQt-specific functions for PySide compatibility.
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
epatters
Clean up in Qt API switcher.
r3306 elif QT_API == QT_API_PYSIDE:
Evan Patterson
Paved the way for PySide support....
r3304 from PySide import QtCore, QtGui, QtSvg
epatters
Clean up in Qt API switcher.
r3306
else:
epatters
Improved error message for Qt API switcher.
r3334 raise RuntimeError('Invalid Qt API %r, valid values are: %r or %r' %
(QT_API, QT_API_PYQT, QT_API_PYSIDE))