def exec_core_event_loop(app): # This works but does not allow IPython injection print('[*guitools] running core application loop.') try: from IPython.lib.inputhook import enable_qt4 enable_qt4() from IPython.lib.guisupport import start_event_loop_qt4 print('Starting ipython qt4 hook') start_event_loop_qt4(app) except ImportError: pass app.exec_()
def _enable_gui(self): """Enable GUI event loop integration.""" config = self.master_config try: # Enable GUI integration if config.Global.wthread: self.log.info("Enabling wx GUI event loop integration") inputhook.enable_wx(app=True) elif config.Global.q4thread: self.log.info("Enabling Qt4 GUI event loop integration") inputhook.enable_qt4(app=True) elif config.Global.gthread: self.log.info("Enabling GTK GUI event loop integration") inputhook.enable_gtk(app=True) except: self.log.warn("Error in enabling GUI event loop integration:") self.shell.showtraceback()
Because of subtle difference in how Matplotlib handles the different GUI toolkits (in things like draw and show), minor modifications to this script have to be made for Tk to get it to work with the 0.99 and below releases of Matplotlib. However, in the future, Matplotlib should be able to have similar logic for all the toolkits, as they are all now using PyOS_InputHook. """ import sys import time from IPython.lib import inputhook gui = inputhook.current_gui() if gui is None: gui = 'qt4' inputhook.enable_qt4(app=True) backends = dict(wx='wxagg', qt4='qt4agg', gtk='gtkagg', tk='tkagg') import matplotlib matplotlib.use(backends[gui]) matplotlib.interactive(True) import matplotlib from matplotlib import pyplot as plt, mlab, pylab import numpy as np from numpy import * from matplotlib.pyplot import * x = np.linspace(0,pi,500)
Because of subtle difference in how Matplotlib handles the different GUI toolkits (in things like draw and show), minor modifications to this script have to be made for Tk to get it to work with the 0.99 and below releases of Matplotlib. However, in the future, Matplotlib should be able to have similar logic for all the toolkits, as they are all now using PyOS_InputHook. """ import sys import time from IPython.lib import inputhook gui = inputhook.current_gui() if gui is None: gui = 'qt4' inputhook.enable_qt4(app=True) backends = dict(wx='wxagg', qt4='qt4agg', gtk='gtkagg', tk='tkagg') import matplotlib matplotlib.use(backends[gui]) matplotlib.interactive(True) import matplotlib from matplotlib import pyplot as plt, mlab, pylab import numpy as np from numpy import * from matplotlib.pyplot import * x = np.linspace(0, pi, 500)