adding python version of init_func_example

This commit is contained in:
Dan Buch 2009-11-18 20:33:10 -05:00
parent 0e6152a741
commit a66477b05f

View File

@ -0,0 +1,33 @@
import sys
import curses
def main():
curses.wrapper(init_func_example)
return 0
def init_func_example(stdscr):
curses.raw()
stdscr.keypad(1)
curses.noecho()
stdscr.addstr(0, 0, "Type any character to see it in bold\n")
ch = stdscr.getch()
if ch == curses.KEY_F1:
stdscr.addstr(1, 0, "F1 Key pressed")
else:
key_pressed = "The pressed key is "
stdscr.addstr(1, 0, key_pressed)
stdscr.attron(curses.A_BOLD)
stdscr.addstr(1, len(key_pressed), chr(ch))
stdscr.attroff(curses.A_BOLD)
stdscr.refresh()
stdscr.getch()
if __name__ == '__main__':
sys.exit(main())
# vim:filetype=python