Tkinter window displaying the time?

William Annis annis at biostat.wisc.edu
Fri Aug 24 15:47:04 EDT 2001


"G. Willoughby" <thecalm at NOSPAM.btinternet.com> writes:

> I thought of using a while 1: loop and providing a 1 second delay with
> sleep(1) to update the title but this don't seem to be working, any ideas???

        With the while 1: loop the event handler will never have a
chance to take over.  You want to schedule an update callback
regularly.  Try this:


from Tkinter import *
from time import *

def titleTime():
    now = strftime("GMT: %I:%M:%S %p", localtime(time()))
    root.title(now)
    # Time in ms.
    root.after(1000, titleTime)

root=Tk()
root.iconify()
titleTime()
root.mainloop()


-- 
William Annis - System Administrator - Biomedical Computing Group
annis at biostat.wisc.edu                       PGP ID:1024/FBF64031
Mi parolas Esperanton - La Internacian Lingvon  www.esperanto.org



More information about the Python-list mailing list