curses problem reading cursor keys

Simon Morgan me at privacy.net
Sat Oct 7 14:57:51 EDT 2006


On Sat, 07 Oct 2006 13:12:33 +0000, Simon Morgan wrote:

> import curses
> 
> def main(scr):
>     status = curses.newwin(1, curses.COLS, 0, 0) status.bkgd('0')
>     status.refresh()
> 
>     list = curses.newwin(curses.LINES, curses.COLS, 1, 0) list.bkgd('X')
>     list.refresh()

If I use scr.subwin() instead of curses.newwin()...

>     y = 0
>     while True:
>         c = list.getch()

and scr.getch() instead of list.getch(), things seem to work. I'd still
really like to know what's going on though.

>         if c in (curses.KEY_UP, curses.KEY_DOWN, ord('z')):
>             list.addstr("Match!")
>         elif c == ord('q'):
>             break
> 
> curses.wrapper(main)



More information about the Python-list mailing list