Created
September 22, 2021 16:18
-
-
Save nautilor/65318b05108a315b1ebccf07d333a143 to your computer and use it in GitHub Desktop.
curses - python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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