0

I used the curses library in Python to divide the screen into two part, the first half to print a set of strings and the second half to get the user input by using getstr() , but when the user enters the ipnut curses interrupt the entry and clear the user's entries

def main(stdscr):
    curses.curs_set(0)
    stdscr.nodelay(1)
    stdscr.timeout(100)
    i = 0
    while 1 :
        i = i+1
        stdscr.addstr(0,0,"frame"+str(i))

        curses.echo()    
        user_input = stdscr.getstr(5,0)

        stdscr.addstr(7,0,user_input)

curses.wrapper(main)

1 Answers1

0

getstr won't help with this. If you want to concurrently update the screen and get input, you'll have to make a function like getstr, using getch, and allowing the getch calls to time-out (to do the addstr calls periodically).

The nodelay function can help with this, though using that tends to use too much processing time. It's usually preferable to use timeout, e.g., 10-20 milliseconds.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105