ncurses' Dark Devilry

Christopher Subich csubich.spam.block at
Tue Nov 29 22:27:38 CET 2005

Jeremy Moles wrote:
>>In article <mailman.1336.1133289146.18701.python-list at>,
>> Jeremy Moles <jeremy at> wrote:
>>>I have a focus "wheel" of sorts that allows the user to do input on
>>>various wigets and windows and whatnot. However, if I want to quickly
>>>call addstr somewhere else in the application I have to:
>>>	1. Store the YX coords of the cursor currently
>>>	2. Use the cursor in the "current" action
>>>	3. Restore the old cursor location

> All of the routines I can find in the ncurses library want to take
> control of the "cursor" object. That is: they either want to advance
> it's position (addstr) or not (addchstr), but they both certainly grab
> "control" of it; at least, visually.
> Basically what I'm looking for is a way to refresh a portion of a
> curses-controlled "window" without affecting the current location of the
> cursor or having to manually move it and move it back.

Why not wrap your 1-3 in a function of your own?  More generally, build 
a 'cursor location stack', probably using a list.  Add utility functions 
push_cur and pop_cur to push and pop the current location of the cursor 
from that stack (pop_cur actually resets the current cursor location for 
future printing).  Then your "write over there" becomes:


which can be pretty easily wrapped in a single function.

Mind you, I don't use curses myself, but what would prevent this from 

More information about the Python-list mailing list