-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCursesTimes.py
More file actions
33 lines (25 loc) · 773 Bytes
/
CursesTimes.py
File metadata and controls
33 lines (25 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import curses
import time
def main(stdscr):
# Configurar curses
curses.curs_set(0)
stdscr.nodelay(1)
stdscr.timeout(1000) # Actualizar cada segundo
while True:
stdscr.clear()
height, width = stdscr.getmaxyx()
# Obtener la hora actual
current_time = time.strftime("%H:%M:%S")
# Centrar el reloj en la pantalla
x = width // 2 - len(current_time) // 2
y = height // 2
# Imprimir la hora actual en el centro de la pantalla
stdscr.addstr(y, x, current_time)
# Refrescar la pantalla
stdscr.refresh()
# Salir si se presiona 'q'
key = stdscr.getch()
if key == ord('q'):
break
if __name__ == "__main__":
curses.wrapper(main)