[SciPy-user] going through a lot of plots

Robert Cimrman cimrman3 at ntc.zcu.cz
Thu May 14 02:30:15 EDT 2009


Zachary Pincus wrote:
>>> I find myself in this situation a lot: I'm looking at a sequence of
>>> plots, one for each piece of data in a collection. I usually find
>>> myself writing a loop with a plot command followed by raw_input()so
>>> that I hit enter in the terminal window IPython session to move to  
>>> the
>>> next item.  I usually make this conditional so that I can process in
>>> batch without looking at the plots if I choose.
>>>
>>> This has the effect of producing a newline in the terminal every time
>>> I want to move on to the next plot, which is far from ideal,
>>> especially in the situation where I'm not printing anything else in
>>> that window.
> 
> 
> Old-school alternative is to put the TTY into cbreak (aka "rare" mode,  
> between "raw" and "cooked"), and capture a single key-hit. (Except  
> that ^C still breaks, which is handy.) For windows, the C runtime has  
> a similar getkey function.
> 
> Here's windows / posix code for that that I've assembled from various  
> snippets online; note that the latter uses the well-known decorator  
> module. I've also included an "iskeydown" function which I find useful  
> in various situations...

I have collected some useful snippets to do a similar thing too - now I 
  merged the functionality, added some sugar (pause functions), stirred 
and cooked - see the attachment.

$ python getch.py

Are you ok with me using it in my (BSD) project?

thanks,
r.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getch.py
Type: text/x-python
Size: 3026 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20090514/6193e823/attachment.py>


More information about the SciPy-User mailing list