Mic wrote:

> I want a function to run every second , how do I do that?
> 
> Say that the function look like this:
> 
> def hi():
>     print("hi")

For a console app you could use a for-loop with time.sleep() or
http://docs.python.org/dev/py3k/library/sched.html

For a script that uses tkinter there's the after() method.
Example:

root = Tk()

def hi():
    print("ho")

def hi_reschedule():
    hi()
    # make tkinter call it again after 1000 milliseconds
    root.after(1000, hi_reschedule) 

hi_reschedule() # call it manually the first time

http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to