我试图在命令行模式下启动Arduino IDE并将标准输出恢复到我的PyQt应用程序中,如下所示:
from PyQt5.QtCore import QObject
from PyQt5.Qt import QProcess
class AsyncProcess(QObject):
def __init__(self, path, slot, parent=None):
super().__init__(parent)
self.path = path
self.proc = None
self.slot = slot
def start(self):
self.proc = QProcess(self)
self.proc.readyReadStandardOutput.connect(self.readStandardOutput)
self.proc.readyReadStandardError.connect(self.readStandardError)
self.proc.start(self.path)
def readStandardOutput(self):
procOutput = self.proc.readAllStandardOutput()
self.slot(procOutput)
def readStandardError(self):
procOutput = self.proc.readAllStandardError()
self.slot(procOutput)
它在QMainWindow函数中调用并且完美无缺(Arduino IDE上传草图!),除了它不会像常规Windows命令提示符调用时那样输出任何消息。
AsyncProcess类如下所示:
from myapp.models import Traffic, Email
class DashboardView(TemplateView):
template_name = "dashboard/pages/dashboard.html"
def get_context_data(self, **kwargs):
context = super(DashboardView, self).get_context_data(**kwargs)
context['email_list'] = Email.objects.all()
context['traffic_list'] = Traffic.objects.all()
return context
如果我开始" ping 127.0.0.1"它可以用于某些原因。而不是Arduino。
有什么想法吗?
答案 0 :(得分:0)
好的,mea culpa。在某些时候,IDE的开发人员决定只在指定的调试版本中输出我需要的信息......我实际上是在调用错误的可执行文件......