curses newwin

M

Michele Simionato

I have just performed this experiment with curses:

from curses import *

maxwidth=79
maxheight=21

def wait4q(stdscr):
scr=stdscr
scr.addstr("Press 'q' to exit\n")
x,y,=0,0
while True:
c=scr.getch()
if c==KEY_LEFT and x > 0:
x-=1; scr.move(y,x)
elif c==KEY_RIGHT and x < maxwidth:
x+=1; scr.move(y,x)
elif c==KEY_UP and y > 0:
y-=1; scr.move(y,x)
elif c==KEY_DOWN and y < maxheight:
y+=1; scr.move(y,x)
elif c==ord('q'):
break

if __name__=='__main__':
wrapper(wait4q)

It works fine and one can move the cursor on the screen. The question
is: why that does not work for a generic window different from stdscr?
i.e. if I replace the line ``scr=stdscr`` with
``scr=newwin(0,0)``I don't see the cursor moving anymore.
The 'q' is still recognized, however. I tried with some
refresh(), but didn't work. What I am missing?

TIA,

Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top