##// END OF EJS Templates
Finishing up the wx, qt4 and tk support. Still have to do gtk.
Finishing up the wx, qt4 and tk support. Still have to do gtk.

File last commit:

r2214:9fca2a63
r2214:9fca2a63
Show More
switchgui.py
48 lines | 925 B | text/x-python | PythonLexer
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213 """Test the new %gui command. Run this in ipython as
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 In [1]: %gui [backend]
In [2]: %run switchgui [backend]
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
where the optional backend can be one of: qt4, gtk, tk, wx.
"""
import sys
import time
from IPython.lib import inputhook
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 gui = inputhook.current_gui()
if gui is None:
gui = 'qt4'
inputhook.enable_qt4(app=True)
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 backends = dict(wx='wxagg', qt4='qt4agg', gtk='gtkagg', tk='tkagg')
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
import matplotlib
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 matplotlib.use(backends[gui])
matplotlib.interactive(True)
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
import matplotlib
from matplotlib import pyplot as plt, mlab, pylab
import numpy as np
from numpy import *
from matplotlib.pyplot import *
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 x = np.linspace(0,pi,500)
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
print "A plot has been created"
line, = plot(x,sin(2*x))
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 inputhook.spin()
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 print "Now, we will update the plot..."
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213 print
for i in range(1,51):
print i,
sys.stdout.flush()
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 line.set_data(x,sin(x*i))
Fernando Perez
In-progress work on trying to get a robust inputhook setup....
r2213 plt.title('i=%d' % i)
plt.draw()
Brian Granger
Finishing up the wx, qt4 and tk support. Still have to do gtk.
r2214 inputhook.spin()