Why curses.initscr() takes no effect in Windows 11 Command Prompt?

134 Views Asked by At

I´m trying to write some programs in Python with windows.curses but when I run the program nothing happens. The code is:

import curses
from curses import wrapper

def main(scr):
    scr.initscr()
    scr.clear()
    scr.addstr(20, 20, "Hello World!")
    scr.refresh()
    scr.getch()

wrapper(main)

When I open a CMD windows and I run "python3 curses_test.py", nothing happens and no error is reported. The prompt just jump to a new line.

Anyone already have this problem? I´m using Windows 11 Professional, Python 3.12.1 and windows.curses 2.3.2.

In linux the same code works perfectly.

1

There are 1 best solutions below

1
pippo1980 On

I don't know on Windows, it is working on iOS. Try this:

import curses

import time

scr = curses.initscr()

def main(scr):
    
    
    scr.clear()
    
    scr.addstr(20, 20, "Hello World!")
    
    scr.refresh()
    
    time.sleep(5)
    
    scr.clear()
    
    scr.refresh()
    
    time.sleep(5)
    
    scr.addstr(20, 20, "Hello World! 2 ")
    
    print('print(scr) : ' , scr)
    
    scr.refresh()
    
main(scr)

and check if it behaves differently.