Created
August 6, 2012 07:01
-
-
Save bibiboot/3271792 to your computer and use it in GitHub Desktop.
Hello world python curses
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
import curses | |
SCREEN_WIDTH, SCREEN_HEIGHT = 100, 100 | |
class curses_screen: | |
def __enter__(self): | |
"""Initialize""" | |
self.stdscr = curses.initscr() | |
curses.cbreak() | |
curses.noecho() | |
self.stdscr.keypad(1) | |
# Initialize max width, height | |
SCREEN_HEIGHT, SCREEN_WIDTH = self.stdscr.getmaxyx() | |
return self.stdscr | |
def __exit__(self,a,b,c): | |
""" | |
Makes sure the exit does not | |
crashes the terminal | |
""" | |
curses.nocbreak() | |
self.stdscr.keypad(0) | |
curses.echo() | |
curses.endwin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment