25

I'm looking into developing a console application in python which should be able to run under Windows as well as Linux. For this, I'd really like to use a high-level console library like curses. However, as far as I know, curses is not available on Windows.

What other options do I have? Unfortunately, using cygwin under Windows is not an option...

Thanks for your help!

Adi Lester
  • 24,731
  • 12
  • 95
  • 110
andreas-h
  • 10,679
  • 18
  • 60
  • 78
  • 2
    so, if i look at your answers, there doesn't seem to be a good solution for my problem ... i will probably try force the users to use cygwin on windows. wish me luck ;) – andreas-h Aug 24 '09 at 18:04
  • 5
    There is a build available of a PDCurses implementation for Python: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses – Dale Bustad Sep 03 '12 at 17:33

5 Answers5

7

There is a wcurses. I've never tried it but it may meet your needs. It sounds like it doesn't have full curses compatibility, but may be close enough. Also it might not be using the DOS terminal, but opening a GUI window and drawing monospaced text inside.

Other windows text mode options are:

I believe both are windows only.

nosklo
  • 217,122
  • 57
  • 293
  • 297
ehempel
  • 182
  • 3
  • 2
    Just a note: last snapshot of `wcurses` in [Curses for Windows & Python - archive.org](http://web.archive.org/web/20101025073658/http://adamv.com/dev/python/curses/) I found is from 2010. – sdaau May 25 '13 at 19:22
7

I recently hit this issue for a package I was putting together (https://github.com/peterbrittain/asciimatics). I wasn't very happy with the solutions that required you to install (or worse) build separate binary executables like PDCurses or cygwin, so I created a unified API that provides console colours, cursor positioning and keyboard & mouse input for Windows, OSX and UNIX platforms.

This is now live and has been tested on CentOS 6/7 and Windows 7/8/10 and OSX 10.11. You can install it from PYPI using pip and then use the Screen class to control your console. As you can see from the project gallery, it should provide all your console needs, but if you need some extra features, please post an enhancement request on GitHub and I'll see what I can do.

Peter Brittain
  • 13,489
  • 3
  • 41
  • 57
5

I don't know why people answer in question comments, but debustad is right, there is a prebuilt curses for Windows:

Note lots of other helpful libraries there too. After doing so, install pip and the (lesser known but excellent) bpython interactive interpreter to try it out immediately:

pip install bpython

I also recommend the Urwid library for something higher-level. Never tried it on Windows, but it should be possible with one of the curses packages.

Gringo Suave
  • 29,931
  • 6
  • 88
  • 75
4

PDCurses works on Windows, but I don't know any Python wrapper. I wonder whether the curses module could be implemented on Windows with PDCurses?

Bastien Léonard
  • 60,478
  • 20
  • 78
  • 95
-8

develop two interfaces for your program, a text console ui and a graphical ui. Make the console one work only on linux. Nobody on windows uses text console apps.

nosklo
  • 217,122
  • 57
  • 293
  • 297
  • 1
    +1 Those that do use text console apps on windows use cygwin, which has ncurses. It's always nice if it's possible to separate the UI from the implementation and this gives a nice incentive to do so. – DrAl Aug 07 '09 at 14:24
  • 10
    If a text UI is sufficient, it would be wasteful to write both text and graphic UIs IMO. – Bastien Léonard Aug 07 '09 at 14:26
  • 5
    well, the people using this app would also use it on windows. especially since they would use it on windows and on linux, so two different interfaces would not be nice to them. plus, i would have to develop two interfaces, which i'd rather not. – andreas-h Aug 07 '09 at 14:29
  • 4
    The question is good - it'd be nice to have portable console code that includes Windows. Saying "make a GUI for Windows" isn't helpful. – moopet Sep 03 '12 at 19:13
  • 1
    `Nobody on windows uses text console apps.` well nope ... like the guys I am currently writing code for. – user26742873 Jul 30 '21 at 08:17