如何使用Python Urwid进行像UI的聊天? [英] How to make a chat like UI using Python Urwid?

查看:1234
本文介绍了如何使用Python Urwid进行像UI的聊天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用gevent和zeromq实现聊天守护进程,但我想为他们制作一个控制台UI。





任何人都有能够执行此操作的代码段?



我不需要整个程序,我可以处理通信,守护程序,选项和所有其余的自己。



基本设置UI,在底部输入一些文本,并且异步通知顶部面板添加一些文本,同时不阻止底部输出。



谢谢

解决方案

在计算中,如果你不聪明,你必须耐心。我只是将好的老的try / except关键字应用到我的编程方法:


  1. 从源中删除与我的功能无关的东西

  2. 如果确定,请转到1,直到只有基本代码仍然存在

  3. 如果崩溃,了解此部分以及为什么它是必需的, =https://gist.github.com/1521153 =nofollow>一个文件。



    它可以工作。现在我得弄清楚如何使urwid和zeromq主循环在一起发挥好。


    I alreay can implement chat daemons using gevent and zeromq, but I'd like to make a console UI for them.

    My first attempt with ncurses failed, so I tried Urwid and found out that the project nigiri was going exactly what I wanted:

    I studied the source code, but being unfamiliar with console UI programming, I failed finding out the part that were producing this result (especially since it used multiple tabs), while I guess I have to play with the connect signal.

    Does anybody have a snippet that can does this ?

    I don't need the whole program, I can handle the communication, the daemons, the options and all the rest myself.

    Just the basics to setup the UI, enter some text at the bottom, and asynchronously notify the top panel to add some text while it doesn't block the bottom ouput.

    Thanks

    解决方案

    In computing, if you are not smart, you gotta be patient. I just applied the good old try/except keyword to my programming method:

    1. remove something from the source that doesn't relate to my feature
    2. if ok, go to 1 until the is only the essential code remains
    3. if it crashes, understand this part and why it's essential and replace it with a code that suit my needs then go back to 2

    I just stripped down the nigiri source code untill it fits in one file.

    It works. Now I gotta figure out how to make the urwid and zeromq main loops play nice together.

    这篇关于如何使用Python Urwid进行像UI的聊天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆