Created
August 6, 2012 07:28
-
-
Save bibiboot/3271927 to your computer and use it in GitHub Desktop.
Running the 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
with curses_screen() as stdscr: | |
""" | |
Execution of the curses begins here. | |
""" | |
# Retrieve the size of the terminal currently open. | |
SCREEN_HEIGHT, SCREEN_WIDTH = stdscr.getmaxyx() | |
# Create the pad | |
mypad = curses.newpad(SCREEN_HEIGHT, SCREEN_WIDTH) | |
# Refresh the pad | |
mypad.refresh(mypad_pos, 0, 0, 0, SCREEN_HEIGHT, SCREEN_WIDTH) | |
while True: | |
# Wait for the user input | |
cmd = mypad.getch() | |
if cmd == 66: | |
# Pressed Keydown | |
# Prints the statement on screen | |
mypad.addstr(0, 0, "Down key is pressed") | |
draw_page(mypad_pos) | |
elif cmd == 65: | |
# Pressed Keyup | |
mypad.addstr(0, 0, "Down key is pressed") | |
elif cmd == ord('q'): | |
# Pressed 'q' | |
# Quit the application | |
break | |
elif cmd == ord('r'): | |
# Pressed r for refresh | |
mypad.addstr(0, 0, "Refresh key is pressed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment