equal
deleted
inserted
replaced
41 event(self, function) |
41 event(self, function) |
42 |
42 |
43 def __init__(self, input, handler=None): |
43 def __init__(self, input, handler=None): |
44 if handler is None: |
44 if handler is None: |
45 handler = self |
45 handler = self |
46 self.handler = handler |
46 self.handler = handler |
47 handler.Bind(wx.EVT_MENU, self.OnIdle) |
47 handler.Bind(wx.EVT_IDLE, self.OnIdle) |
48 handler.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded, id=-1) |
48 handler.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded) |
49 |
49 |
50 input.reverse() # so we can pop |
50 input.reverse() # so we can pop |
51 self.input = input |
51 self.input = input |
52 |
52 |
53 self.reset() |
53 self.reset() |
54 |
54 |
91 self.process = None |
91 self.process = None |
92 |
92 |
93 def kill(self): |
93 def kill(self): |
94 if self.process is not None: |
94 if self.process is not None: |
95 self.process.CloseOutput() |
95 self.process.CloseOutput() |
96 if wx.Process_Kill(self.pid, wx.SIGTERM) != wx.KILL_OK: |
96 if wx.Process.Kill(self.pid, wx.SIGTERM) != wx.KILL_OK: |
97 wx.Process_Kill(self.pid, wx.SIGKILL) |
97 wx.Process.Kill(self.pid, wx.SIGKILL) |
98 self.process = None |
98 self.process = None |
99 |
99 |
100 def updateStream(self, stream, data): |
100 def updateStream(self, stream, data): |
101 if stream and stream.CanRead(): |
101 if stream and stream.CanRead(): |
102 if not self.responded: |
102 if not self.responded: |
154 def wxPopen3(cmd, input, output, errors, finish, handler=None): |
154 def wxPopen3(cmd, input, output, errors, finish, handler=None): |
155 p = ProcessRunnerMix(input, handler) |
155 p = ProcessRunnerMix(input, handler) |
156 p.setCallbacks(output, errors, finish) |
156 p.setCallbacks(output, errors, finish) |
157 p.execute(cmd) |
157 p.execute(cmd) |
158 return p |
158 return p |
159 |
159 |
160 |
160 def _test(): |
|
161 app = wx.PySimpleApp() |
|
162 f = wx.Frame(None, -1, 'asd')#, style=0) |
|
163 f.Show() |
|
164 |
|
165 def output(v): |
|
166 print 'OUTPUT:', v |
|
167 def errors(v): |
|
168 print 'ERRORS:', v |
|
169 def fin(): |
|
170 p.Close() |
|
171 f.Close() |
|
172 print 'FINISHED' |
|
173 |
|
174 |
|
175 def spin(p): |
|
176 while not p.finished: |
|
177 wx.Yield() |
|
178 time.sleep(0.01) |
|
179 |
|
180 def evt(self, event): |
|
181 input = [] |
|
182 p = wxPopen3('''c:\\python23\\python.exe -c "print '*'*5000"''', |
|
183 input, output, errors, fin, f) |
|
184 print p.pid |
|
185 |
|
186 app.MainLoop() |
|
187 |
|
188 if __name__ == '__main__': |
|
189 _test() |