# it would lead to crash import sys if woo.runtime.hasDisplay and ('PyQt4' not in sys.modules) and ('PySide' not in sys.modules): if 11<woo.runtime.ipython_version()<120: try: import IPython.external.qt # in later IPython version, the import itself does everything already IPython.external.qt.prepare_pyqt4() except AttributeError: pass if 1: # initialize QApplication from PyQt4 import QtGui if woo.runtime.ipython_version()==10: wooQApp=QtGui.QApplication(sys.argv) elif useQtConsole: from IPython.frontend.qt.console.qtconsoleapp import IPythonQtConsoleApp wooQApp=IPythonQtConsoleApp() wooQApp.initialize() else: # create an instance of InteractiveShell before the inputhook is created # see http://stackoverflow.com/questions/9872517/how-to-embed-ipython-0-12-so-that-it-inherits-namespace-of-the-caller for details # fixes http://gpu.doxos.eu/trac/ticket/40 try: from IPython.terminal.embed import InteractiveShellEmbed # IPython>=1.0 except ImportError: from IPython.frontend.terminal.embed import InteractiveShellEmbed # IPython<1.0 from IPython.config.configurable import MultipleInstanceError try: ipshell=InteractiveShellEmbed.instance() except MultipleInstanceError: print 'Already running inside ipython, not embedding new instance.' # keep the qapp object referenced, otherwise 0.11 will die with "QWidget: Must construct QApplication before a QPaintDevice # see also http://ipython.org/ipython-doc/dev/interactive/qtconsole.html#qt-and-the-qtconsole import IPython.lib.inputhook #guisupport
if not woo.runtime.hasDisplay: raise ImportError(woo.runtime.hasDisplayError) # disable all IPython warnings (sometimes imported for the first time here, not in woo's __init__.py or wooMain) import warnings warnings.filterwarnings('ignore', category=DeprecationWarning, module='.*IPython.*') if 'qt5' in woo.config.features: from PyQt5 import QtGui from PyQt5.QtWidgets import QApplication if useQtConsole: from IPython.frontend.qt.console.qtconsoleapp import IPythonQtConsoleApp wooQApp = IPythonQtConsoleApp() wooQApp.initialize() else: # create an instance of InteractiveShell before the inputhook is created # see http://stackoverflow.com/questions/9872517/how-to-embed-ipython-0-12-so-that-it-inherits-namespace-of-the-caller for details # fixes http://gpu.doxos.eu/trac/ticket/40 from IPython.terminal.embed import InteractiveShellEmbed # IPython>=1.0 try: from traitlets.config.configurable import MultipleInstanceError except: from IPython.config.configurable import MultipleInstanceError # produces ShimWarning try: ipshell = InteractiveShellEmbed.instance() except MultipleInstanceError: log.warning( 'Already running inside ipython, not embedding new instance.')