On 05/29/2017 03:14 PM, 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.
Poul Riis
### The following two lines should be replaced by
### something like "Go on until some key is pressed - then break"
if plt.waitforbuttonpress():
break
Hello,
What about
try:
for i in range(20): plot1.plot([20*(sin(i/10)+1)],[cos(i/10)],'bo')
except KeyboardInterrupt:
pass # you could also print a message
You'd be using CTRL+C to interrupt the loop.
jm
--
https://mail.python.org/mailman/listinfo/python-list