curses problem reading cursor keys

Rainy ak at silmarill.org
Sat Oct 7 21:40:49 CEST 2006


Simon Morgan wrote:
> 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)

I don't have a linux here now but I vaguely remember running into this.
I think what I did was just writing down what code you do get when
pressing down and up, etc, and using that code. By the way I looked
around back then and didn't find any thorough tutorials on curses,
either.




More information about the Python-list mailing list