curses curiosity
Christopher Swingley
cswingle at iarc.uaf.edu
Mon May 12 13:47:33 EDT 2003
Greetings!
This morning I was playing with the curses module and have hit upon
something I can't figure out. I won't go so far as to call it a bug,
since these things usually work out to programmer error.
Here's a sample program demonstrating the curiosity:
#! /usr/bin/env python
import curses
import curses.wrapper
def main(window):
(max_y, max_x) = window.getmaxyx()
window.addch(max_y - 1, max_x - 2, ord('+')) # OK
window.addch(max_y - 2, max_x - 1, ord('+')) # OK
window.addch(max_y - 1, max_x - 1, ord('+')) # ERR?
window.refresh()
while 1:
c = window.getch()
if c == ord('q'):
break
curses.wrapper(main)
When run, this results in:
Traceback (most recent call last):
File "./curses_bug.py", line 18, in ?
curses.wrapper(main)
File "/usr/lib/python2.2/curses/wrapper.py", line 44, in wrapper
res = apply(func, (stdscr,) + rest)
File "./curses_bug.py", line 10, in main
window.addch(max_y - 1, max_x - 1, ord('+')) # ERR?
_curses.error: addch() returned ERR
(Python 2.2.2, Debian GNU/Linux unstable)
My understanding is that getmaxyx() returns the columns and rows of the
window, which would mean that one minus each should yield the lower
right corner of the screen. The two lines above the error demonstrate
that I can access the spaces just above and to the left of the mytical
lower right corner. FYI, I also tried window.addstr(), with the same
results.
What am I doing wrong? How does one put a character in the lower right
corner?
Thanks,
Chris
--
Christopher S. Swingley email: cswingle at iarc.uaf.edu
IARC -- Frontier Program Please use encryption. GPG key at:
University of Alaska Fairbanks www.frontier.iarc.uaf.edu/~cswingle/
More information about the Python-list
mailing list