Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Smarter Qt binding selection when environment variable is not specified.

  • Loading branch information...
commit 41c5017436af28f802d8fcfc43508626118c15d4 1 parent 5163e14
Evan Patterson authored

Showing 1 changed file with 21 additions and 4 deletions. Show diff stats Hide diff stats

  1. +21 4 IPython/external/qt.py
25 IPython/external/qt.py
@@ -7,10 +7,7 @@
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 @@
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.

0 comments on commit 41c5017

Please sign in to comment.
Something went wrong with that request. Please try again.