MCPcopy Create free account
hub / github.com/LabPy/lantz / import_pyqt4

Function import_pyqt4

lantz/utils/qt_loaders.py:182–216  ·  view source on GitHub ↗

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

(version=2)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

check_versionFunction · 0.85

Tested by

no test coverage detected