MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / load_qt

Function load_qt

pydev_ipython/qt_loaders.py:303–381  ·  view source on GitHub ↗

Attempt to import Qt, given a preference list of permissible bindings It is safe to call this function multiple times. Parameters ---------- api_options: List of strings The order of APIs to try. Valid items are 'pyside', 'pyqt', and 'pyqtv1' Returns

(api_options)

Source from the content-addressed store, hash-verified

301
302
303def load_qt(api_options):
304 """
305 Attempt to import Qt, given a preference list
306 of permissible bindings
307
308 It is safe to call this function multiple times.
309
310 Parameters
311 ----------
312 api_options: List of strings
313 The order of APIs to try. Valid items are 'pyside',
314 'pyqt', and 'pyqtv1'
315
316 Returns
317 -------
318
319 A tuple of QtCore, QtGui, QtSvg, QT_API
320 The first three are the Qt modules. The last is the
321 string indicating which module was loaded.
322
323 Raises
324 ------
325 ImportError, if it isn't possible to import any requested
326 bindings (either becaues they aren't installed, or because
327 an incompatible library has already been installed)
328 """
329 loaders = {
330 QT_API_PYSIDE: import_pyside,
331 QT_API_PYSIDE2: import_pyside2,
332 QT_API_PYSIDE6: import_pyside6,
333 QT_API_PYQT: import_pyqt4,
334 QT_API_PYQTv1: partial(import_pyqt4, version=1),
335 QT_API_PYQT_DEFAULT: partial(import_pyqt4, version=None),
336 QT_API_PYQT5: import_pyqt5,
337 QT_API_PYQT6: import_pyqt6,
338 }
339
340 for api in api_options:
341 if api not in loaders:
342 raise RuntimeError(
343 "Invalid Qt API %r, valid values are: %r, %r, %r, %r, %r, %r, %r"
344 % (api, QT_API_PYSIDE, QT_API_PYSIDE2, QT_API_PYQT, QT_API_PYQTv1, QT_API_PYQT_DEFAULT, QT_API_PYQT5, QT_API_PYQT6)
345 )
346
347 if not can_import(api):
348 continue
349
350 # cannot safely recover from an ImportError during this
351 result = loaders[api]()
352 api = result[-1] # changed if api = QT_API_PYQT_DEFAULT
353 commit_api(api)
354 return result
355 else:
356 raise ImportError(
357 """
358 Could not load requested Qt binding. Please ensure that
359 PyQt4 >= 4.7 or PySide >= 1.0.3 is available,
360 and only one is imported per session.

Callers 2

qt.pyFile · 0.90
qt_for_kernel.pyFile · 0.90

Calls 4

can_importFunction · 0.85
commit_apiFunction · 0.85
loaded_apiFunction · 0.85
has_bindingFunction · 0.85

Tested by

no test coverage detected