Menu

curses library is not displaying window unless mvwin() method is run

Reddit r/learnpython·u/9mHoq7ar4Z·7 months ago
#SJh5YMRz
#stdscr#curses#refresh#screen#mvwin
Reading 0:00
15s threshold

Hi

Im trying to learn the curses library but have come across something that I do not understand.

When I run the code below the stdscr and win update as per expectation. But as soon as you press a key (to get past the stdscr.getkey()) the win object disappears from the screen (even though the win.refresh() method is run)

What I have found is that if I include a win.mvwin() method then the win object will appear just find in the screen.

Im uncertain why this is occuring and was hoping that someone could explain this too me?

import time import curses from curses import wrapper def main(stdscr): win = curses.newwin(10,40,10,10) win.border() # Paint screen and wait for input stdscr.refresh() win.refresh() stdscr.getkey() # Paint screen but win does not appear stdscr.erase() stdscr.refresh() # win.mvwin(10,10) # Uncommenting results in win appearing win.refresh() time.sleep(10) wrapper(main)