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

F

fuzziy

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()
 
G

Gabriel Genellina

[why does my python's program die after change computer system time?]
def tick():
...show current time...
clock_label.after(200, tick)

What do you mean by "die"?
Did you set the system time to an earlier value? Suppose now it is
09:15:00.000; your program says after(200, tick), that means that at
09:15:00.200 the tick() function will be called. If you
set the time back to 09:00:00 your program has 15 minutes still to wait.
It hasn't died, it's just waiting for the right time to arrive.

I'm not sure if this can be considered a bug, or not, or who's responsible
(tcl? tk? tkinter? python?...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top