The following is a sample code which demonstrates how to utilize
the classes defined in this module.
import curses
from curses_button import Button, Text
stdscr = curses.initscr()
curses.noecho()
stdscr.keypad(True)
b1 = Button(stdscr, 0, 0, "One", '1')
b2 = Button(stdscr, 0, 10, "Two", '2')
b3 = Button(stdscr, 0, 20, "Three", '3')
buttons = [b1, b2, b3]
statusBar = Text(stdscr, 23, 0, "Status:", 0)
while True:
c = stdscr.getkey()
if c == 'q': break
for b in buttons:
if b.getKey() == c:
statusBar.setText("You press " + b.caption)
curses.endwin()