2014-12-05 6 views
1

exectuable을 호출하는 pydide 앱이 있습니다. 이 프로세스를 n 프로세스에서 비동기 적으로 실행하고 QTextEdit에서 각 프로세스의 출력을 캡처하려고합니다. 순간 Pyside : TextEdit에 다중 QProcess 출력

는 내가 가진 : 프로세스가 '준비'신호를 보내는 각 시간과 너무 투박

def run(self, args, worklist):   

    self.viewer = OutputDialog(self) 

    self.procs = [] 
    for path in worklist: 
     final_args = args + path 

     p = QtCore.QProcess(self) 
     p.readyReadStandardOutput.connect(self.write_process_output) 
     self.procs.append(p) 
     p.start(self.exe, final_args) 

def write_process_output(self): 
    for p in self.procs: 
     self.viewer.text_edit.append(p.readAllStandardOutput()) 

, 그것은 모든 프로세스의 출력을 얻기 위해 시도합니다.

신호를 보낸 프로세스의 출력 만 가져올 수 있습니까?

 p.readyReadStandardOutput.connect(
      lambda process=p: self.write_process_output(process)) 


    def write_process_output(self, process): 
     self.viewer.text_edit.append(process.readAllStandardOutput()) 

답변

2

는 관련 프로세스가 슬롯으로 전달되도록 lambda를 사용하여 신호를 연결한다.
+0

그레이트 용액을 환호 : – jramm