adding python version of init_func_example
This commit is contained in:
parent
0e6152a741
commit
a66477b05f
33
basics/init_func_example.py
Normal file
33
basics/init_func_example.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user