donnieh
Feb 12, 2015 - 06:15
What is a simple way to have a timer call a function every 10 seconds?
What is a simple way to have a timer call a function every 10 seconds?
It depends a little on what you're trying to do with it, is it in the context of a program with UI, or do you just print to the console?
It will be used in a UI. Every 10 seconds I am going to call a function that a button on my UI also can call. (this is an auto feature in my app...)
def button_tapped():
#this gets called with a button tap, or automatically every 10 seconds by a timer
import time
for x in range(1, 100):
time.sleep(10.0)
#commands
See: https://github.com/cclauss/Pythonista_ui/blob/master/TimedRefreshView.py