2016-11-04 102 views
2

我有一个Python 3.4应用程序使用PyQt5框架,我有一个问题。PyQt5 QProcess的冲洗缓冲区

我设置一个QProcess中:

def listenToServer(self, MainWindow): 
    self.ws = QtCore.QProcess(self) 
    self.ws.start("python3 /home/pi/scara_panel/ws.py") 
    self.ws.readyReadStandardOutput.connect(self.processServer) 

它调用此函数:

def processServer(self): 
    income = str(self.ws.readAllStandardOutput()) 
    print(income) 

在桌面,它工作正常。它流入应用程序。但是,当程序在Raspberry Pi上运行时,只会显示脚本ws.py终止后的内容。

我读过这与Python中的输出缓冲有关。我尝试过添加-u标志,但没有骰子。有关如何在使用readAllStandardOutput()时清除此缓冲区的建议?

我试过从Disable output buffering实施一些东西,但似乎没有解决这个问题。

任何帮助表示赞赏!

回答