call a function every n mseconds

Michele Simionato michele.simionato at poste.it
Sun Feb 22 05:54:56 EST 2004


Vedran Furac <vedranfREMOVE at riteh.hr> wrote in message news:<slrnc3fuec.8pk.vedranf at rijeka.riteh.hr>...
> How can I call a function every time a specified number of milliseconds
> elapses? Javascript has setInterval() function and I need something like
> that. Currently I use this:
> def function():
> 	[...]
> 	t = threading.Timer(n, function)
> 	t.start()
> function()

You can fork the process and use time.sleep. Or you can use Tkinter
(hint: Tkinter also works for non-graphical applications): Tkinter
widgets have an "after" method that does what you want.

          Michele Simionnato



More information about the Python-list mailing list