Skip to content

Instantly share code, notes, and snippets.

@nautilor
Created September 22, 2021 16:18
Show Gist options
  • Save nautilor/65318b05108a315b1ebccf07d333a143 to your computer and use it in GitHub Desktop.
Save nautilor/65318b05108a315b1ebccf07d333a143 to your computer and use it in GitHub Desktop.
curses - python
#!/usr/bin/env python3
import curses
def init_screen():
stdscr = curses.initscr()
curses.echo()
curses.nocbreak()
curses.start_color()
curses.use_default_colors()
curses.raw()
return stdscr
stdscr = init_screen()
user_input = ""
while not "exit" in user_input:
key = stdscr.getch()
if key == 8 or key == 127 or key == curses.KEY_BACKSPACE:
stdscr.addstr("\b \b")
else:
user_input += chr(key)
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment