[IPython-user] pylab threading mode for embedded IPython
Fernando Perez
Fernando.Perez at colorado.edu
Mon Dec 26 02:30:50 CST 2005
Yaroslav Bulatov wrote:
> When I run IPython with -pylab option it works fine. But if I try the
> same with embedded IPython it'll wait until I close the plot window,
> am I doing something wrong?
>
> from pylab import *
> from IPython.Shell import IPShellEmbed
> plot([1,2,3])
> IPShellEmbed(['-pylab'])()
>
> In [1]: show()
Yes, unfortunately the threading/pylab features are not supported by the
embedded ipython, only by the free-standing one. Note, however, that _if you
use a Tk-based backend_, you can use embedded ipython with matplotlib
interactively. The trick is to manually call ion() yourself to mimic
interactive mode, the following example shows how:
#!/usr/bin/env python
from pylab import *
from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed()
ipshell.IP.runlines('from pylab import ion; ion()')
plot([1,2,3])
ipshell()
# end file
I realize that this is a hack, and it's limited to Tkinter-based backends.
However, I'm afraid that clean support for this will probably have to wait
until the entire hierarchy of shell classes in ipython gets a cleanup and full
reorganization in the chainsaw development branch.
Cheers,
f
More information about the IPython-user
mailing list