Mundo em Python

Horas de Portugal e de Espanha (usando Tkinter)

from tkinter import *
from datetime import datetime
import pytz
import time root= Tk()
root.geometry("400x500")
root.config(bg='white')
root.resizable(False,False)
def update():
new_timezone = pytz.timezone("Europe/Madrid")
hora_local = datetime.now(new_timezone)
tempo_actual = hora_local.strftime('%H:%M:%S')
horas2.config(text=tempo_actual)
horas2.after(1000,update)
clock.config(text=time.strftime("%I:%M:%S"))
clock.after(1000,update)
textportugal = Label(text="Portugal",bg = 'white',fg = 'black', font = ('arial', 40, 'bold'))
textportugal.place(relx=0.2,rely=0.05)
clock = Label( bg = 'white',fg = 'green', font = ('arial', 40, 'bold'))
clock.place(relx=0.2,rely=0.25)
textespanha = Label(text="Espanha",bg = 'white',fg = 'black', font = ('arial', 40, 'bold'))
textespanha.place(relx=0.2,rely=0.45)
horas2 = Label( bg = 'white',fg = 'red', font = ('arial', 40, 'bold'))
horas2.place(relx=0.2,rely=0.7)
update()
root.title('Horas de Portugal e de Espanha')
root.mainloop()
0