MCPcopy Create free account
hub / github.com/ipython/ipython / import_pyqt4

Function import_pyqt4

IPython/external/qt_loaders.py:177–211  ·  view source on GitHub ↗

Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable

(version=2)

Source from the content-addressed store, hash-verified

175
176
177def import_pyqt4(version=2):
178 """
179 Import PyQt4
180
181 Parameters
182 ----------
183 version : 1, 2, or None
184 Which QString/QVariant API to use. Set to None to use the system
185 default
186
187 ImportErrors rasied within this function are non-recoverable
188 """
189 # The new-style string API (version=2) automatically
190 # converts QStrings to Unicode Python strings. Also, automatically unpacks
191 # QVariants to their underlying objects.
192 import sip
193
194 if version is not None:
195 sip.setapi('QString', version)
196 sip.setapi('QVariant', version)
197
198 from PyQt4 import QtGui, QtCore, QtSvg
199
200 if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
201 raise ImportError("IPython requires PyQt4 >= 4.7, found %s" %
202 QtCore.PYQT_VERSION_STR)
203
204 # Alias PyQt-specific functions for PySide compatibility.
205 QtCore.Signal = QtCore.pyqtSignal
206 QtCore.Slot = QtCore.pyqtSlot
207
208 # query for the API version (in case version == None)
209 version = sip.getapi('QString')
210 api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT
211 return QtCore, QtGui, QtSvg, api
212
213
214def import_pyqt5():

Callers

nothing calls this directly

Calls 1

check_versionFunction · 0.90

Tested by

no test coverage detected