Skip to content Skip to sidebar Skip to footer

Curses Window.getstr()

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

Solution 1:

The traceback tells you, that the variable mystr is a bytes object not a string. This means you have to decode it first, before you can use it as a string, which is needed by addstr().

Here's the change you need to make:

mystr = window.getstr(6,20).decode(encoding="utf-8")

This is a Python 3 problem ONLY! I tested this with Python 2.7 as well, which works without this change. The problem arises due to different bytes/string handling between Python 2 and 3. I assume you followed through a py2 tutorial while using py3 yourself.

Post a Comment for "Curses Window.getstr()"