Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import curses
- import atexit
- from datetime import datetime
- import time
- from threading import Timer
- stdscr = None
- current_time = datetime.now()
- do_exit = False
- def init_curses():
- global stdscr
- stdscr = curses.initscr()
- curses.start_color()
- curses.noecho()
- curses.cbreak()
- stdscr.nodelay(1)
- atexit.register(exit_curses)
- return
- def exit_curses():
- curses.echo()
- curses.nocbreak()
- curses.endwin()
- return
- def update_time():
- global current_time
- global stdscr
- global do_exit
- current_time = datetime.now().time()
- stdscr.addstr(1,1, current_time.isoformat(), curses.color_pair(0))
- if do_exit == False:
- Timer(1, update_time, ()).start()
- init_curses()
- Timer(1, update_time, ()).start()
- while do_exit == False:
- key = stdscr.getch()
- if key == ord('q'):
- do_exit = True
- elif key == ord('t'):
- stdscr.addstr(0,0,"TEE ON PAINETTU!", curses.color_pair(0))
- elif key == ord('w'):
- stdscr.addstr(0,0,"TUPLAWEE ON PAINETTUD!", curses.color_pair(0))
- exit_curses()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement