Exemplo n.º 1
0
def get_options():
    """Return a list of acceptable QT APIs, in decreasing order of
    preference
    """
    #already imported Qt somewhere. Use that
    loaded = loaded_api()
    if loaded is not None:
        return [loaded]

    mpl = sys.modules.get('matplotlib', None)

    if mpl is not None and not check_version(mpl.__version__, '1.0.2'):
        #1.0.1 only supports PyQt4 v1
        return [QT_API_PYQT_DEFAULT]

    if os.environ.get('QT_API', None) is None:
        #no ETS variable. Ask mpl, then use either
        return matplotlib_options(mpl) or [QT_API_PYQT_DEFAULT, QT_API_PYSIDE]

    #ETS variable present. Will fallback to external.qt
    return None


api_opts = get_options()
if api_opts is not None:
    QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)

else:  # use ETS variable
    from IPython.external.qt import QtCore, QtGui, QtSvg, QT_API
Exemplo n.º 2
0
                      mpqt)

def get_options():
    """Return a list of acceptable QT APIs, in decreasing order of
    preference
    """
    #already imported Qt somewhere. Use that
    loaded = loaded_api()
    if loaded is not None:
        return [loaded]

    mpl = sys.modules.get('matplotlib', None)

    if mpl is not None and not check_version(mpl.__version__, '1.0.2'):
        #1.0.1 only supports PyQt4 v1
        return [QT_API_PYQT_DEFAULT]

    if os.environ.get('QT_API', None) is None:
        #no ETS variable. Ask mpl, then use either
        return matplotlib_options(mpl) or [QT_API_PYQT_DEFAULT, QT_API_PYSIDE]

    #ETS variable present. Will fallback to external.qt
    return None

api_opts = get_options()
if api_opts is not None:
    QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)

else: # use ETS variable
    from IPython.external.qt import QtCore, QtGui, QtSvg, QT_API
Exemplo n.º 3
0
 def test_prevent_multi_import_qtdefault(self):
     from IPython.external.qt_loaders import load_qt
     load_qt(['pyqtdefault'])
     with pytest.raises(ImportError) as exc:
         import PySide
     assert exc.value.args[0].strip().startswith('Importing PySide')
Exemplo n.º 4
0
 def test_prevent_incompatible_qt_multimport(self):
     from IPython.external.qt_loaders import load_qt
     load_qt(['pyqt'])
     with pytest.raises(ImportError) as exc:
         load_qt(['pyqtv1'])
     assert exc.value.args[0].strip().startswith('Could not load')
Exemplo n.º 5
0
 def test_prevent_multi_import_pyside(self):
     from IPython.external.qt_loaders import load_qt
     load_qt(['pyside'])
     with pytest.raises(ImportError) as exc:
         import PyQt4
     assert exc.value.args[0].strip().startswith('Importing PyQt4 disabled')