python - 如何在 PySide 中获取 QProcess 运行的命令的输出?

标签 python qt python-3.x pyside qprocess

我想知道如何在 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/

相关文章:

python - 更改 SpaCy 优化器中的默认学习率

Python GTK属性错误: 'gi.repository.Gtk' object has no attribute 'FlowBox'

python - Python 中的 HTML 标签验证

python - 在加载图层的函数最终加载图层之后,如何调用函数?

python - 如何在 Pandas 中读取 .txt

python - 将图像从 python 传输到 C++ 并返回

python - 在保留布局的同时更改 XML

c++ - 读取分离进程的控制台输出

c++ - 项目错误 : Unknown module(s) in QT: quick

c++ - 从 QFontDatabase::addApplicationFont 获取字体系列名称