Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 19, 2021 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/1fe0e5e27de51fc860c1b9f0b30fbe8d to your computer and use it in GitHub Desktop.
Save parzibyte/1fe0e5e27de51fc860c1b9f0b30fbe8d to your computer and use it in GitHub Desktop.
"""
https://parzibyte.me/blog
"""
from datetime import datetime
import tkinter as tk
INTERVALO_REFRESCO_RELOJ = 300 # En milisegundos
def obtener_hora_actual():
return datetime.now().strftime("%H:%M:%S")
def refrescar_reloj():
print("Refrescando!")
variable_hora_actual.set(obtener_hora_actual())
raiz.after(INTERVALO_REFRESCO_RELOJ, refrescar_reloj)
raiz = tk.Tk()
variable_hora_actual = tk.StringVar(raiz, value=obtener_hora_actual())
raiz.etiqueta = tk.Label(
raiz, textvariable=variable_hora_actual, font=f"Consolas 60")
raiz.etiqueta.pack(side="top")
app = tk.Frame()
raiz.title("Reloj en Tkinter - By Parzibyte")
refrescar_reloj()
app.pack()
app.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment