Is there a way to create a separate display and input on the same terminal using curse?

非 Y 不嫁゛ 提交于 2019-12-01 16:40:14

问题


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.


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/5727554/is-there-a-way-to-create-a-separate-display-and-input-on-the-same-terminal-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!