wx.Process
서브 클래스를 만들려고하는데 사용자 정의 프로세스 시작 프로그램을 사용하여 stdout 스트림에서 수집 된 데이터로 메인 스레드로 이벤트를 다시 발생시킵니다. 이것은 일을하는 좋은 방법입니까? 여기 wx.Process에서 내 메인 스레드로 정보를 전파하는 가장 좋은 방법은 무엇입니까?
class BuildProcess(wx.Process):
def __init__(self, cmd, notify=None):
wx.Process.__init__(self, notify)
print "Constructing a build process"
self.Bind(wx.EVT_IDLE, self.on_idle)
self.Redirect()
self.cmd = cmd
self.pid = None
def start(self):
print "Starting the process"
self.pid = wx.Execute(self.cmd, wx.EXEC_ASYNC, self)
print "Started."
def on_idle(self, evt):
print "doing the idle thing..."
stream = self.GetInputStream()
if stream.CanRead():
text = stream.read()
wx.PostEvent(self, BuildEvent(EVT_BUILD_UPDATE, self, data=text))
print text
def OnTerminate(self, *args, **kwargs):
wx.Process.OnTerminate(self, *args, **kwargs)
print "Terminating"
BuildEvent
wx.PyEvent
의 사용자 정의 서브 클래스입니다. 프로세스가 시작, 실행 중이고 올바르게 종료되지만 내 유휴 이벤트에 바인드 했음에도 불구하고 내
on_idle
기능이 실행되지 않습니다.