有没有办法使用curse在同一终端上创建单独的显示和输入?
我想编写一个命令行程序来生成此 UI:
------------
| |
| A |
|__________|
|_____B____|
A 是一个单独的进程,它循环并显示实时事件列表。它会自动刷新。
B 是命令提示符。它固定在底部并有命令历史记录。
我知道一些命令行 IRC 程序会执行此操作,因此它一定是可能的。
如果您能给我一个使用 Python 绑定的代码片段,那就加分了。
我知道这篇文章,但我有点迷失在诅咒文档。
I'd like to code a command line program that result in this UI:
------------
| |
| A |
|__________|
|_____B____|
A is a separate process that loops and displays a list of real time events. It self-refresh.
B is a command prompt. It's fixed at the bottom and got a command history.
I know some command line IRC programs does this so it must be possible.
Bonus point if you can give me a snippet using a Python binding.
I'm aware of this post but I'm kind of lost in the curse documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最终我尝试使用 urwid 来实现,它的级别比 ncurse 高得多。
我在 SO 上问了一个问题,但没有得到更多结果。
但最终我发现了一些可以做到这一点的自由开源软件,我使用了源代码并制作了一些有用的东西。您可以在相关中找到答案问题。
Enventually I tried to do it with urwid which is way higher level than ncurse.
I asked a question about it on SO and didn't got more results.
But eventually I found some FOSS that did just that, I used the source code and made something that worked. You can find the answer in the related question.
看看
/Demo/curses/
python 源代码目录。它列出了几个使用curses模块的有趣示例,您可以从中学习您需要的所有内容,甚至更多。Have a look at the
/Demo/curses/
directory of the python source code. It lists several intersting examples using the curses module that you can learn all you need from, and some more.对于后代 - 这是您想要的架构的一个很好的实现,用 urwid (一个 ncurses 包装器)编写: http://zderadicka.eu/terminal-interfaces-in-python/#comment-123799
需要进行一些调整才能将其变成聊天客户端,但使用管道做到这一点非常简单。作者的代码在github上: https://github.com/izderadicka/ xmpp-tester/blob/master/commander.py
For posterity - this is a great implementation of the architecture you desire, written with urwid (an ncurses wrapper): http://zderadicka.eu/terminal-interfaces-in-python/#comment-123799
It took some tweaking to turn it into a chat client, but it's pretty simple to do so with pipes. The author's code is on github: https://github.com/izderadicka/xmpp-tester/blob/master/commander.py