Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import curses
  2.  
  3. stdscr = curses.initscr()
  4. stdscr.keypad(True)
  5.  
  6. def add_text(text):
  7.     stdscr.addstr(text)
  8.  
  9. def add_line(text):
  10.     stdscr.addstr(text + '\n')
  11.  
  12. while True:
  13.     # Disable echo to get the command key
  14.     curses.noecho()
  15.     c = stdscr.get_wch()
  16.     if c == 'q':
  17.         # Exit the while loop
  18.         break
  19.     elif c == 'e':
  20.         # Enable echo to get user input
  21.         curses.echo()
  22.         s = stdscr.getstr(10)
  23.         add_line('got: %s' % s)
  24.     elif c == curses.KEY_LEFT:
  25.         add_line('<-')
  26.     elif c == curses.KEY_RIGHT:
  27.         add_line('->')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement