[Tutor] str.split and quotes

Kent Johnson kent37 at tds.net
Mon Apr 11 22:55:22 CEST 2005

Alberto Troiano wrote:
> Thanks Kent but now I need you to explain me the code :(

That code won't work for you. It is for timing how long it takes to do something, not for generating 
repeated events.

> To give you a graphic example how can make this function to run every 5 
> seconds
> def foo():
>     print "Hello world!"

Here is a Tkinter program that updates the text of a label every second. It uses the root.after() 
method to schedule a callback. Since it is a one-time callback, the callback reschedules itself each 
time it is called.

This is not a great example of code structure but it is simple and demonstrates the concept.

from Tkinter import *

count = 0

def update():
     ''' Callback method updates the label '''
     global count
     count += 1

     # Schedule another callback
     root.after(1000, update)



# Schedule the initial callback
root.after(1000, update)



More information about the Tutor mailing list