Hi Marc, I'm not very familiar with IPython (probably to my
> detriment), but I believe this may be an inherent problem
> with wx v. command-line program, and have little to do with
> MPlot, matplotlib, or IPython. That is, I think that
> wxWidgets/wxPython's MainLoop() is never really going to
> interact well with a command-line application. I'd be happy
ipython has a wx mode (-pylab with a wx* backend or -wthread for
general wx apps) which is designed to allow you to control wx apps
from the ipython shell. It does this by starting the wx application
mainloop and then hijacking the wx mainloop so that application
attempts to start the mainloop will be ignored.
"""Modifies wxPython's MainLoop with a dummy so user code does not
block IPython. The hijacked mainloop function is returned.
it then runs a wx timer to check for input from the shell user.
The bulk of this was written by Fernando and myself, and neither of
us pretend to be wx experts, so it is quite possible that something is
not working right and can be improved. It might be as simple as a
need to update the hijack function for a new version of wx. Or it
might be something deep, subtle and nasty. Or it might simply be user
error. Without example code that replicates the problem, it's
difficult to say.
I suggest that Marc try and run some of the embedding_in_wx*
applications in the matplotlib examples dir from the ipython shell and
see if these work. And then gradually add some of the functionality
you are using in your real app (eg dynamic updates).
Marc, my guess is that you are mixing programming idioms (OO and
pylab). For an application like yours, you should not be using pylab
at all, and I see that you are with the pylab.ion call. You should
follow the examples of embedding_in_wx* and then call
fig.canvas.draw() when you want your figure to draw. Note that
interactive mode will not affect OO calls, eg even if you do
you will still need to do
since the interactive mode only applies to *pylab* plot commands, eg,
Recode your application so that pylab is imported nowhere, and call
canvas.draw() when you need the canvas to update. You can post pylab
snippets here if you need help translating them to OO matplotlib.