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

Discussion in 'Python' started by fuzziy, Jun 3, 2009.

  1. fuzziy

    fuzziy Guest

    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()
     
    fuzziy, Jun 3, 2009
    #1
    1. Advertisements

  2. 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?...)
     
    Gabriel Genellina, Jun 3, 2009
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.