0

I made this code. I need an update every second, but I can't use .after(1000,func) like.after(1000, func) like a clock. I can't use time.sleep(1). I don't know what else to do. Please help me solve this.

import tkinter
from datetime import datetime

agora = datetime.now()
encontro = datetime.strptime('03/08/2016/13', "%d/%m/%Y/%H")
delta = encontro - agora

n_dias = delta.days
n_horas = int(delta.seconds/3600)
n_min = int((delta.seconds - n_horas*3600)/60)
n_seg = int(delta.seconds - n_horas*3600 - n_min*60)

texto1 = tkinter.Label()
texto1['text'] = "Quanto tempo para ver minha lindinha:"
texto1['font'] = "Times 8 bold"
texto1.pack()

dias = tkinter.Label()
dias['font'] = "Times 8 bold"

horas = tkinter.Label()
horas['font'] = "Times 8 bold"

minutos = tkinter.Label()
minutos['font'] = "Times 8 bold"

e = tkinter.Label()
e['font'] = "Times 8 bold"
e['text'] = 'e'

segundos = tkinter.Label()
segundos['font'] = "Times 8 bold"

if n_dias!=1:
    dias['text'] = n_dias,"Dias"
else: dias['text'] = n_dias,"Dia"

if n_horas!=1:
    horas['text'] = n_horas,"Horas"
else: horas['text'] = n_horas,"Hora"

if n_min!=1:
    minutos['text'] = n_min,"minutos"
else: minutos['text'] = n_min,"minuto"

if n_seg!=1:
    segundos['text'] = n_seg,"segundos"
else: segundos['text'] = n_seg,"segundo"

dias.pack(side="left")
horas.pack(side="left")
minutos.pack(side="left")
e.pack(side="left")
segundos.pack(side="left")

Thank you. I need to write more to post it --'

0 Answers0