# Make the controls
prompt = wxStaticText(self, -1, 'Command line:')
- self.cmd = wxTextCtrl(self, -1, 'python data/echo.py')
+ self.cmd = wxTextCtrl(self, -1, 'python -u data/echo.py')
self.exBtn = wxButton(self, -1, 'Execute')
self.out = wxTextCtrl(self, -1, '', style=wxTE_MULTILINE|wxTE_READONLY)
self.inp = wxTextCtrl(self, -1, '', style=wxTE_PROCESS_ENTER)
self.sndBtn = wxButton(self, -1, 'Send')
self.termBtn = wxButton(self, -1, 'Close Stream')
- self.inp.Enable(false)
- self.sndBtn.Enable(false)
- self.termBtn.Enable(false)
+ self.inp.Enable(False)
+ self.sndBtn.Enable(False)
+ self.termBtn.Enable(False)
# Hook up the events
EVT_BUTTON(self, self.exBtn.GetId(), self.OnExecuteBtn)
sizer.Add(box2, 0, wxEXPAND|wxALL, 10)
self.SetSizer(sizer)
- self.SetAutoLayout(true)
+ self.SetAutoLayout(True)
def __del__(self):
self.process = wxProcess(self)
self.process.Redirect();
- pid = wxExecute(cmd, false, self.process)
+ pid = wxExecute(cmd, wxEXEC_ASYNC, self.process)
self.log.write('OnExecuteBtn: "%s" pid: %s\n' % (cmd, pid))
- self.inp.Enable(true)
- self.sndBtn.Enable(true)
- self.termBtn.Enable(true)
- self.cmd.Enable(false)
- self.exBtn.Enable(false)
+ self.inp.Enable(True)
+ self.sndBtn.Enable(True)
+ self.termBtn.Enable(True)
+ self.cmd.Enable(False)
+ self.exBtn.Enable(False)
self.inp.SetFocus()
def OnCloseStream(self, evt):
self.log.write('OnCloseStream\n')
- print "b4 CloseOutput"
+ #print "b4 CloseOutput"
self.process.CloseOutput()
- print "after CloseOutput"
+ #print "after CloseOutput"
def OnIdle(self, evt):
if self.process is not None:
stream = self.process.GetInputStream()
- # Yes, this is weird. For this particular stream, EOF
- # simply means that there is no data available to be read,
- # not truly the end of file. Also, read() just reads all
- # the currently available data, not until the real EOF...
- if not stream.eof():
+ if stream.CanRead():
text = stream.read()
self.out.AppendText(text)
(evt.GetPid(), evt.GetExitCode()))
stream = self.process.GetInputStream()
- if not stream.eof():
+ if stream.CanRead():
text = stream.read()
self.out.AppendText(text)
self.process.Destroy()
self.process = None
- self.inp.Enable(false)
- self.sndBtn.Enable(false)
- self.termBtn.Enable(false)
- self.cmd.Enable(true)
- self.exBtn.Enable(true)
+ self.inp.Enable(False)
+ self.sndBtn.Enable(False)
+ self.termBtn.Enable(False)
+ self.cmd.Enable(True)
+ self.exBtn.Enable(True)
#----------------------------------------------------------------------
</body><html>
"""
+
+
+
+
+
+if __name__ == '__main__':
+ import sys,os
+ import run
+ run.main(['', os.path.basename(sys.argv[0])])