tags:

views:

83

answers:

2

First thought of implementing this using threads but python doesnt have a way for killing threads. I have read the other topic on killing threads. Is there any proper platform independent way of doing this?

A: 

Can you be more specific? This could be done in pygame, but you'd need to open a graphical window.

Jeffrey Aylesworth
A: 

I think you'd better use a Tk timer for ringing periodically, and then stop it when you get the key press.

See http://www.java2s.com/Code/Python/GUI-Tk/Clockevent.htm for an example how to use timer.

Thus you will avoid creating another thread.

EFraim
Is it possible to stop the timer after getting a keypress? http://python.active-venture.com/lib/timer-objects.html - Here I find that you can stop the timer only before the action starts.
dante
@dante: you can just not reactivate it. (not call .after)
EFraim
http://code.activestate.com/recipes/492231/- This helped me.
dante