我想知道如何在 PySide 中捕获 QProcess 运行的命令的输出,以便显示它。
最佳答案
我最终使用了这个:
# Create runner
self.runner = QProcess(self)
# Make sure newInfo gets all output
self.runner.readyReadStandardError.connect(self.newErrInfo)
# Run the command
self.runner.start(command)
# Once it's started set message to Converting
self.parentWidget().statusBar().showMessage("Converting.")
然后在类里面:
def newErrInfo(self):
newString = str(self.runner.readAllStandardError())
print(newString, end=" ")
readAllStandardOutput() 也适用于标准输出
关于python - 如何在 PySide 中获取 QProcess 运行的命令的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10657419/