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)
| 175 | |
| 176 | |
| 177 | def 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 | |
| 214 | def import_pyqt5(): |
nothing calls this directly
no test coverage detected