why does my python's program die after change computer system time?

fuzziy zhiyongfore at gmail.com
Wed Jun 3 03:08:03 EDT 2009


Microsoft windowsXP 中,在python2.6下运行如下程序,显示一个时间的窗口。当双击桌面右下角的时间,然后更改时间或日
期,多次更改后,我的时间窗口就死机了,时间不变了。好像是after(200, tick)不运行了。不知道为怎么这个定时器会死掉呢。请各位指教,
谢谢!!

import Tkinter
import time

curtime = ''
clock_label = Tkinter.Label()
clock_label.pack()

def tick():
    global curtime
    #print("1:")
    newtime = time.strftime('%Y-%m-%d %H:%M:%S')
    if newtime != curtime:
        curtime = newtime
        clock_label.config(text=curtime)
    clock_label.config(text=newtime)
    clock_label.after(200, tick)
    #print(curtime)

tick()
clock_label.mainloop()



More information about the Python-list mailing list