Poul Riis wrote: > In good old pascal there was this one-liner command: > repeat until keypressed > > Apparently there is no built-in analogue for that in python. I have > explored several different possibilities (pyglet, keyboard, curses, ginput > (from matplotlib) and others) but not managed to find anything that works > the way I want. > > In the following example I just want to replace 'waitforbuttonpress' with > something like 'continueuntilbuttonpress' if such a command exists. It > could be a mouseclick or a keystroke from the terminal, for instance > 'shift', 'space' or some character.
How about combining waitforbuttonpress() with pause()? import warnings warnings.filterwarnings("ignore", ".*GUI is implemented.*") from pylab import * def plot_them(): plot1 = subplot(2, 1, 1) plot2 = subplot(2, 1, 2) for i in range(20): plot1.plot([20*(sin(i/10)+1)], [cos(i/10)], 'bo') if waitforbuttonpress(timeout=0.1): return for i in range(20): plot2.plot([20*(sin(i/10)+1)], [-cos(i/10)], 'ro') if waitforbuttonpress(timeout=0.1): return ion() plot_them() waitforbuttonpress() ioff() -- https://mail.python.org/mailman/listinfo/python-list