from tkinter import *
import pytz
from datetime import datetime
root = Tk()
root.geometry("800x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Horas em Nova York, Londres, Tóquio e São Paulo")
titulo = Label(text="Horas em Nova York, Londres, Tóquio e São Paulo",
font=("Arial", "23", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05)
# Define timezones and city names
city_names = {
'America/New_York': 'Nova York',
'Europe/London': 'Londres',
'Asia/Tokyo': 'Tóquio',
'America/Sao_Paulo': 'São Paulo'
}
# Create labels for each city
labels = {
timezone: Label(root, font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
for timezone in city_names
}
# Place the labels on the window
positions = [0.25, 0.4, 0.55, 0.7]
for (timezone, label), pos in zip(labels.items(), positions):
label.place(relx=0.05, rely=pos)
# Update function for each city's time
def atualizar_horas():
for timezone, label in labels.items():
tz = pytz.timezone(timezone)
hora_atual = datetime.now(tz)
city = city_names[timezone] # Get city name from the dictionary
label.config(text=f"A hora em {city} é: {hora_atual.strftime('%d-%m-%Y %H:%M:%S')}")
root.after(1000, atualizar_horas) # Update every second
atualizar_horas()
root.mainloop()