from tkinter import *
from datetime import datetime
root = Tk()
root.geometry("700x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Paragem de Autocarro")
titulo = Label(text="Paragem de Autocarro",
font=("Arial", 28, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.2, rely=0.05)
texto_sub1 = Label(text="Autocarro 1",
font=("Arial", 18, "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.15, rely=0.4)
texto_sub2 = Label(text="Autocarro 2",
font=("Arial", 18, "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.58, rely=0.4)
texto_sub3 = Label(text="A calcular...", font=("Arial", 18, "bold"),
bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.1, rely=0.55)
texto_sub4 = Label(text="A calcular...", font=("Arial", 18, "bold"),
bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.55, rely=0.55)
def calcular_tempo_restante(hora_destino):
agora = datetime.now()
hora_atual = agora.hour * 3600 + agora.minute * 60 + agora.second
hora_alvo = hora_destino.hour * 3600 + hora_destino.minute * 60
return hora_alvo - hora_atual
def atualizar_tempo():
hora_alvo1 = datetime.strptime("15:30", "%H:%M").time()
hora_alvo2 = datetime.strptime("16:00", "%H:%M").time()
segundos_faltantes1 = calcular_tempo_restante(hora_alvo1)
segundos_faltantes2 = calcular_tempo_restante(hora_alvo2)
mensagem1 = f"Faltam {segundos_faltantes1} segundos."\
if segundos_faltantes1 > 0 else "O autocarro já passou!"
mensagem2 = f"Faltam {segundos_faltantes2} segundos." \
if segundos_faltantes2 > 0 else "O autocarro já passou!"
texto_sub3.config(text=mensagem1)
texto_sub4.config(text=mensagem2)
root.after(1000, atualizar_tempo)
atualizar_tempo()
root.mainloop()