我现在正在尝试使我的PC上的GUI与每个套接字的服务器通信。在
以下是GUI的部分代码:def listenToServer(self):
""" keep listening to the server until receiving 'All Contracts Finished' """
self.feedbackWindow.appendPlainText('--Executing the Contracts, Listening to Server--')
contentsListend = ''
while contentsListend != 'All Contracts Finished':
#keep listen from the socket
contentsListend = self.skt.recv(1024)
#make the GUI show the text
self.feedbackWindow.appendPlainText(contentsListend)
另一方面,服务器将逐个发送数据,但间隔一定。下面是模拟服务器的测试代码:
^{pr2}$
现在,一切正常,除了这个问题之外,GUI只会在服务器中的整个for循环之后显示接收到的消息。
一旦我运行了服务器和GUI。服务器端以正确的速度将消息逐个打印到屏幕上,但是GUI没有响应,它不更新。直到程序结束,所有7行代码都在GUI端同时出现。我希望它们一个接一个地出现,这样以后我就可以在我的电脑上用这个图形用户界面来检查服务器的状态
有谁能帮忙吗,非常感谢!在