Animation while waiting for keyboard input
Hello Everybody,
I was wondering what the best way would be to show an animation (a shrinking rectangle indicating how much time a person has left to answer a question) while waiting for a key response of the participant?
My current approach would be something like this (pseudocode):
while time < allowed_time and key is None:
key, time = my_keyboard.get_key(keylist = ..., timeout = 20) #very small timeout so that the animation can update smoothly
my_canvas.rect(....) #update rectangle to slightly smaller rectangle
canvas.show()
But I'm worried that my animation will not work smoothly or that the key response will not be recorded correctly.
Does anybody have a better idea?
Comments
Hi,
Your pseudocode is precisely how I would do it. So I suggest you give it a go, and see how it works. In case it should not be smooth, you can play around with the timeout parameter. (15-20ms should be good enough).
Eduard
Hello,
Just reporting back that this method works adequatly.
Great!. Thanks for getting back!