Skip to content

Instantly share code, notes, and snippets.

@bibiboot
Created August 6, 2012 07:28
Show Gist options
  • Save bibiboot/3271927 to your computer and use it in GitHub Desktop.
Save bibiboot/3271927 to your computer and use it in GitHub Desktop.
Running the python curses
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