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.
我正在研究在python中开发一个控制台应用程序,它应该能够在Windows和Linux下运行。为此,我非常希望使用像curses这样的高级控制台库。然而,据我所知,在Windows上不能使用curses。
What other options do I have? Unfortunately, using cygwin under Windows is not an option...
我还有别的选择吗?不幸的是,在Windows下使用cygwin不是一个选项……
Thanks for your help!
谢谢你的帮助!
5 个解决方案
#1
6
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.
有一个wcurses。我从未试过,但它可能会满足你的需要。听起来它没有完全的诅咒兼容性,但可能已经足够接近了。它也可能不使用DOS终端,而是打开一个GUI窗口,在里面画一个等间距的文本。
Other windows text mode options are:
其他的windows文本模式选项如下:
- The console module;
- 控制台模块;
- wconio -- based on Borland's C conio library.
- wconio——基于Borland的C conio库。
I believe both are windows only.
我相信这两款都是windows专用的。
#2
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?
PDCurses适用于Windows,但我不知道任何Python包装器。我想知道curses模块是否可以用PDCurses在Windows上实现?
#3
3
I don't know why people answer in question comments, but debustad is right, there is a prebuilt curses for Windows:
我不知道为什么人们会在问题评论中回答,但是debustad是对的,Windows有一个预先构建好的诅咒:
- http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
- http://www.lfd.uci.edu/ gohlke pythonlibs / #诅咒
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和(不太知名但很优秀的)bpython交互式解释器,以便立即进行测试:
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.
我还推荐Urwid库用于更高级别的内容。从来没有在Windows上尝试过,但它应该可以用其中一个诅咒包。
#4
3
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.
最近,我为一个我放在一起的包打了这个问题(https://github.com/peterbrittain/asciimatics)。我对需要您安装(或更糟)构建单独的二进制可执行文件(如PDCurses或cygwin)的解决方案不太满意,因此我创建了一个统一的API,为Windows、OSX和UNIX平台提供控制台颜色、光标定位和键盘和鼠标输入。
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.
这款软件现在已经在CentOS 6/7、Windows 7/8/10和osx10.11上进行了测试。您可以使用pip在PYPI上安装它,然后使用屏幕类来控制您的控制台。正如您从项目库中看到的,它应该提供所有您的控制台需求,但是如果您需要一些额外的特性,请在GitHub上发布一个增强请求,我将看看我能做什么。
#5
-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.
为您的程序开发两个接口,一个文本控制台ui和一个图形用户界面。让控制台1只在linux上工作。windows上没有人使用文本控制台应用程序。
#1
6
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.
有一个wcurses。我从未试过,但它可能会满足你的需要。听起来它没有完全的诅咒兼容性,但可能已经足够接近了。它也可能不使用DOS终端,而是打开一个GUI窗口,在里面画一个等间距的文本。
Other windows text mode options are:
其他的windows文本模式选项如下:
- The console module;
- 控制台模块;
- wconio -- based on Borland's C conio library.
- wconio——基于Borland的C conio库。
I believe both are windows only.
我相信这两款都是windows专用的。
#2
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?
PDCurses适用于Windows,但我不知道任何Python包装器。我想知道curses模块是否可以用PDCurses在Windows上实现?
#3
3
I don't know why people answer in question comments, but debustad is right, there is a prebuilt curses for Windows:
我不知道为什么人们会在问题评论中回答,但是debustad是对的,Windows有一个预先构建好的诅咒:
- http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
- http://www.lfd.uci.edu/ gohlke pythonlibs / #诅咒
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和(不太知名但很优秀的)bpython交互式解释器,以便立即进行测试:
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.
我还推荐Urwid库用于更高级别的内容。从来没有在Windows上尝试过,但它应该可以用其中一个诅咒包。
#4
3
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.
最近,我为一个我放在一起的包打了这个问题(https://github.com/peterbrittain/asciimatics)。我对需要您安装(或更糟)构建单独的二进制可执行文件(如PDCurses或cygwin)的解决方案不太满意,因此我创建了一个统一的API,为Windows、OSX和UNIX平台提供控制台颜色、光标定位和键盘和鼠标输入。
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.
这款软件现在已经在CentOS 6/7、Windows 7/8/10和osx10.11上进行了测试。您可以使用pip在PYPI上安装它,然后使用屏幕类来控制您的控制台。正如您从项目库中看到的,它应该提供所有您的控制台需求,但是如果您需要一些额外的特性,请在GitHub上发布一个增强请求,我将看看我能做什么。
#5
-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.
为您的程序开发两个接口,一个文本控制台ui和一个图形用户界面。让控制台1只在linux上工作。windows上没有人使用文本控制台应用程序。