Pause/waitforbuttonpress behavior.

Hi,

I am looking to have ipython pause to show me a figure and wait for me
to press a key before it updates the figure. I see that raw_input()
does not let the figure update presumably because it blocks the gui
thread. On the other hand, pylab.waitforbuttonpress works but only
takes keys that were sent to the gui. I would love to be able to
press enter or something on the ipython command prompt to allow the
script to continue. Is this possible?

I was thinking that it might be possible to use timeouts to keep
switching between the window and the console looking for input. Any
ideas here?

Thanks,
Jonathan.

Wow... changing to TkAgg backend makes raw_input() just work. I
suppose this is because the Tk thread does not need the GIL to render?
Is there a downside to using TkAgg? I am also noticing that it is
much faster than GtkAgg.

Jon.

···

On Sun, Mar 8, 2009 at 2:55 PM, Jonathan Taylor <jonathan.taylor@...649...> wrote:

Hi,

I am looking to have ipython pause to show me a figure and wait for me
to press a key before it updates the figure. I see that raw_input()
does not let the figure update presumably because it blocks the gui
thread. On the other hand, pylab.waitforbuttonpress works but only
takes keys that were sent to the gui. I would love to be able to
press enter or something on the ipython command prompt to allow the
script to continue. Is this possible?

I was thinking that it might be possible to use timeouts to keep
switching between the window and the console looking for input. Any
ideas here?

Thanks,
Jonathan.

If you want different backends than tkagg (that plays nice with
interactive interpreters), you could try

$ ipython -pylab

that is able to identify the wanted backend and work correctly with it
while keeping the interactive prompt available.

Cheers,

···

On Sun, Mar 8, 2009 at 21:03, Jonathan Taylor <jonathan.taylor@...649...> wrote:

Wow... changing to TkAgg backend makes raw_input() just work. I
suppose this is because the Tk thread does not need the GIL to render?
Is there a downside to using TkAgg? I am also noticing that it is
much faster than GtkAgg.

--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

Yes I already use this, but I think the problem is that the other
toolkits need the GIL to update but raw_input() also grabs the GIL so
you cannot examine your plot in a pause (i.e. raw_input()). I think
that TK is able to avoid this problem as a side effect of being in a
"C thread" instead of a python thread which is a side effect of being
part of the python distribution. I think.

Jon.

···

On Mon, Mar 9, 2009 at 4:13 PM, Sandro Tosi <morph@...10...> wrote:

On Sun, Mar 8, 2009 at 21:03, Jonathan Taylor > <jonathan.taylor@...649...> wrote:

Wow... changing to TkAgg backend makes raw_input() just work. I
suppose this is because the Tk thread does not need the GIL to render?
Is there a downside to using TkAgg? I am also noticing that it is
much faster than GtkAgg.

If you want different backends than tkagg (that plays nice with
interactive interpreters), you could try

$ ipython -pylab

that is able to identify the wanted backend and work correctly with it
while keeping the interactive prompt available.

Cheers,
--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

I have no idea whether this is related with the GIL. Anyhow, you may
work around this by running the blocking function in a separate
thread, although I only tested this with Gtk backends. Here is a
related post.

http://sourceforge.net/mailarchive/forum.php?thread_name=6e8d907b0803101609s7bd8fecaj851a6ecf1ab2a316%40mail.gmail.com&forum_name=matplotlib-devel

It is based on the old version of mpl but still seems to work.
The recent version of the mpl have better support for this
(blocking_input.py) and the code should be reimplemented.

-JJ

···

On Mon, Mar 9, 2009 at 4:32 PM, Jonathan Taylor <jonathan.taylor@...649...> wrote:

Yes I already use this, but I think the problem is that the other
toolkits need the GIL to update but raw_input() also grabs the GIL so
you cannot examine your plot in a pause (i.e. raw_input()). I think
that TK is able to avoid this problem as a side effect of being in a
"C thread" instead of a python thread which is a side effect of being
part of the python distribution. I think.

Jon.

On Mon, Mar 9, 2009 at 4:13 PM, Sandro Tosi <morph@...10...> wrote:

On Sun, Mar 8, 2009 at 21:03, Jonathan Taylor >> <jonathan.taylor@...649...> wrote:

Wow... changing to TkAgg backend makes raw_input() just work. I
suppose this is because the Tk thread does not need the GIL to render?
Is there a downside to using TkAgg? I am also noticing that it is
much faster than GtkAgg.

If you want different backends than tkagg (that plays nice with
interactive interpreters), you could try

$ ipython -pylab

that is able to identify the wanted backend and work correctly with it
while keeping the interactive prompt available.

Cheers,
--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options