Skip to main content
 首页 » 编程设计

python之Pyside 客户端和服务器

2025年05月04日6虾米姐

我刚开始学习 python 来使用 raspberry,我的最终目标是通过在 raspberry 之间创建 p2p 网络来制作客户端/服务器应用程序。我选择使用库 asyncore 来制作客户端和服务器,最初使用 pygame 来制作图形,现在我正在尝试使用 PySide,但我遇到了问题。

如何将 asyncore.loop() 集成到 pyside 的主循环中?

请您参考如下方法:

你试过吗?

class ClientThread(threading.Thread): 
 
# Start the thread for the socket 
def __init__(self, server, port, user, gui): 
    threading.Thread.__init__(self) 
    self.client = ClientConnection(server, int(port), user, gui) 
 
# Run the asyncore loop 
def run(self): 
    try: 
        asyncore.loop() 
    except: 
        return 0 

这个例子也许对你有用: https://github.com/absolution/Month-2--Chat-Client-/blob/master/ClientGUI.py