I'm starting to learn curses in Python. I use Python 3.5 on Mac OS X. When I try to write in the lower right corner, the program crashes with the following error:
$ python ex_curses.py [...] File "ex_curses.py", line 19, in do_curses screen.addch(mlines, mcols, 'c') _curses.error: add_wch() returned ERR
Program Example:
import curses def do_curses(screen): curses.noecho() curses.curs_set(0) screen.keypad(1) (line, col) = 12, 0 screen.addstr(line, col, "Hello world!") line += 1 screen.addstr(line, col, "Hello world!", curses.A_REVERSE) screen.addch(0, 0, "c") (mlines, mcols) = screen.getmaxyx() mlines -= 1 mcols -= 1 screen.addch(mlines, mcols, 'c') while True: event = screen.getch() if event == ord("q"): break curses.endwin() if __name__ == "__main__": curses.wrapper(do_curses)
I have a feeling that I am missing something obvious, but I donβt know what.
source share