I am running Windows 7 with Python 2.7 and I installed the curses
module with pip
using the wheel file located at http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses. I followed the basic instructions at https://docs.python.org/2/howto/curses.html for initializing curses
; namely, from a Python command prompt,
import curses
stdscr=curses.initscr()
and nothing happens except that I am unable to type anything more in the command window and I have to close it, although it appears no actual error has occurred. The cursor continues blinking as though awaiting input, but I'm unable to control it any more.
What am I doing wrong?
Copying and pasting from the console window below.
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> stdscr=curses.initscr()
>>>
A screen seems to flash on but immediately disappears and the console becomes useless (although as mentioned the cursor continues blinking... it is not "unresponsive" in the typical sense. It just doesn't respond to keyboard input.).
You will not be able to do much that is useful with the curses package in an interactive command-line shell as shown in the question, because the curses package initializes the input to a raw mode (or equivalent on Windows) so that it can capture individual keys.
The command-line shell uses line-buffering, and given the change of input mode, it will not get lines.
Rather, you will get best results by running a complete script - which would call getch
or getstr
to read input from the terminal window.