That would be a solution, indeed.  However, is there really no way of coming back to a pre-plt.show() state once all windows are closed?  What kind of irreversible things does plt.show() do?
Thanks,
Antony

2010/4/20 Ryan May <rmay31@gmail.com>
On Tue, Apr 20, 2010 at 11:38 AM, Antony Lee <antony.lee@ensmp.fr> wrote:
> Hello,
>
> I'm currently writing a specialized image processing package using
> Matplotlib. The goal would be to let users use it interactively from an
> ipython console.
> So I have some functions for selecting points on plots (via
> "button_press_event"), and others for data plotting (and also for data
> processing, of course). When the user calls a plotting or a
> point-selecting function, I have to call plt.show() at the end of it... but
> then this seems to do something irreversible which cannot be cancelled
> e.g. by plt.ioff(). But at the same time I can't stay in show() mode
> forever, because if I did so, the program would fail when the user calls
> another point-selecting function (as the call to the point-selecting
> function becomes non-blocking, Python raises an error when the yet undefined
> coordinates are read in a following part of the enclosing function). (For
> the same reason, trying to use ipython -pylab leads to failure starting
> from the *first* call to a point-selecting function (instead of the second
> when using ipython).)
> (And I can't use plt.ginput as I sometimes want to update the plot using
> some home-made functions while the user selects data on it).
> So I have to find a way of showing the plot(s) to the user, and still come
> back to pre- plt.show() mode after (of course, if there was a way to show
> the plots without calling plt.show(), that would work too)... I believe this
> is a "classic" question, but I haven't found an answer to it. So does anyone
> have an idea about it?

What you really need is to have ipython integrated into your GUI's
event loop (which is started with show). You might want to look at
http://code.google.com/p/spyderlib/ or Google around for some other
packages that integrate IPython into a GUI.

Ryan

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________