Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import curses
- stdscr = curses.initscr()
- stdscr.keypad(True)
- def add_text(text):
- stdscr.addstr(text)
- def add_line(text):
- stdscr.addstr(text + '\n')
- while True:
- # Disable echo to get the command key
- curses.noecho()
- c = stdscr.get_wch()
- if c == 'q':
- # Exit the while loop
- break
- elif c == 'e':
- # Enable echo to get user input
- curses.echo()
- s = stdscr.getstr(10)
- add_line('got: %s' % s)
- elif c == curses.KEY_LEFT:
- add_line('<-')
- elif c == curses.KEY_RIGHT:
- add_line('->')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement