Python ncurses、CDK、urwid 区别

发布于 2024-12-19 06:04:57 字数 155 浏览 0 评论 0原文

这3个有什么区别?据我了解,它们都提供了对curses的绑定,curses是用于基于终端文本的UI的C库。

我目前对这三者一无所知,也从未使用过诅咒。您会推荐哪一款?我多次听说过 ncurses,但关于 CDK (通过研究)只听说过一两次,而且从未听说过 urwid (我认为)。

What's the difference between these 3? As far as I understand it they both provide binding to curses which is the C library for terminal text-based UI.

I currently have no knowledge of any of the 3 and I've never used curses. Which one would you recommend? I've heard of ncurses many times but only once or twice about CDK (through research) and never heard of urwid (I think).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野稚 2024-12-26 06:04:57

看了一些参考资料后我得到的是:

  • ncurses:这是一个自由软件版本的curses,所以你必须处理所有类型的低级细节。
  • pyCDK:它是一个更高级别的库,提供了一些小部件。我还没有使用过这个,但根据 sourceforge 项目页面,它已经很长时间没有维护了(至少是 python 绑定),所以我不会使用这个。
  • urwid:我用过这个,我不得不说它的水平仍然有点低(它更一个框架而不是一个小部件库),但仍然非常有用,并且比curses更用户友好。作为一个 UI 框架,它拥有您通常期望的所有内容,例如小部件、事件以及控制小部件布局的方法。我想说的一些事情对于 curses 来说很难,但是对于 urwid 来说很容易:在调整终端大小时重绘您的小部件并收集鼠标输入(单击按钮) , 例如)。

因此,我的建议是使用 urwid,如果它不能满足您的需求,请寻找其他替代方案。

What I get after looking at some references is:

  • ncurses: It's a free software version of curses, so you have to deal with all kind low-level details.
  • pyCDK: It's a higher level library that provides some widgets. I haven't used this one, but according to the sourceforge project page it's been unmaintained for a long time (at least the python binding), so I wouldn't go with this one.
  • urwid: I've used this one and I've to say it's still a little bit low level (it's more a framework than a widget library), but still quite useful and much user-friendlier than curses. As a UI framework it has all the stuff you'd typically expect like widgets, events and a way to control the layout of the widgets. Some things that I'd say are hard with curses, but are easy with urwid are: redraw your widgets when the terminal is resized and gather mouse input (clicking on a button, for example).

So my recommendation would be to use urwid and if it doesn't meet your needs look for other alternatives.

蓝眼睛不忧郁 2024-12-26 06:04:57

我没有使用过任何库,但我假设您指的是:

它们只是具有相同目标的不同库:为基于控制台的 UI 提供 API。从上一个问题来看,似乎curses需要更多低级样板。需要注意的一件事是,Python 的 curses 模块仅在 Unix 下可用;如果您使用的是 Windows,您可能需要查看控制台 模块由 Fredrik Lundh 编写。

其他两种选择似乎也很有前途,尽管 urwid 就开发而言看起来更有组织性,并且仍在积极开发中。

I haven't used any of the libraries, but I'm assuming that you're referring to:

They're just different libraries with the same goal: provide an API for a console-based UI. From a previous question, it seems that curses requires more low-level boilerplate. One thing to note is that Python's curses module is only available under Unix; if you're on Windows, you may want to look at the Console module written by Fredrik Lundh.

Both of the other choices seem promising as well, although urwid looks to be more organized as far as development goes, and is still being actively developed somewhat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文