I'm trying to learn curses for Python on Windows XP. I can get the window.getkey command to work correctly but the command window.getstr not only fails but the program exits. Here are sample code lines:
x = window.getkey() # this works
y = window.getstr() # this fails
Obviously, to get the first line to work I have correctly imported curses and have done the stdscr = curses.initscr()
command. My window is defined and working. I've tried placing the window coordinates within the getstr parens and I've used window.move. Neither works.
Any ideas why getstr doesn't work?
Here's more info following the first suggestion:
First, the suggestion to run the program in a command prompt window instead of from the desktop is a good one because the window was indeed disappearing.
Here's the entirety of the program:
# program = testcurses
import curses
stdscr = curses.initscr()
window = stdscr.subwin(23,79,0,0)
window.box()
window.refresh()
window.addstr(2,10, "This is my line of text")
window.addstr(4,20,"What happened? ")
window.refresh()
mykey = window.getkey(5,20)
mystr = window.getstr (6,20)
#window.addstr (7,1, "Key data should be here: ")
#window.addstr (7,33, mykey)
window.addstr (8,1, "Str data should be here: ")
window.addstr (8,33,mystr)
window.refresh()
I remarked the lines pertaining to the display of the key data since that works OK.
Here's the relevant part of the Traceback message:
window.addstr (8,33,mystr)
TypeError: must be str, not bytes.
Tom