Using curses, how can I echo and capture input at the current cursor position? I have moved the cursor using scr.move(y,x) and turned on echoing. I can type into it and have it displayed. How can I capture this data as a string after the user presses enter?

There's a bunch of different ways:

curses.echo()            # Enable echoing of characters
# Get a 10-character string, with the cursor at pos x,y
s = stdscr.getstr(x,y, 15)
curses.echo()
c = stdscr.getch() # gets ascii integer value of character pressed on keyboard (use chr() function to convert it to an actual character)

Thank you very much! It's great that you can specify the length and position all inside that one function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.