Forum Archive

Timer

donnieh

What is a simple way to have a timer call a function every 10 seconds?

omz

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?

donnieh

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

reefboy1
import time
for x in range(1, 100):
   time.sleep(10.0)
   #commands
ccc

See: https://github.com/cclauss/Pythonista_ui/blob/master/TimedRefreshView.py