]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxProcess.py
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / demo / wxProcess.py
index c2ba5ba1ecaf4787af5cfa664dc9c829e7431986..b9bd6ceb66d69136d573f949a90b6918a4c64db3 100644 (file)
@@ -27,9 +27,9 @@ class TestPanel(wxPanel):
         self.inp = wxTextCtrl(self, -1, '', style=wxTE_PROCESS_ENTER)
         self.sndBtn = wxButton(self, -1, 'Send')
         self.termBtn = wxButton(self, -1, 'Close Stream')
         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)
 
         # Hook up the events
         EVT_BUTTON(self, self.exBtn.GetId(), self.OnExecuteBtn)
@@ -55,7 +55,7 @@ class TestPanel(wxPanel):
         sizer.Add(box2, 0, wxEXPAND|wxALL, 10)
 
         self.SetSizer(sizer)
         sizer.Add(box2, 0, wxEXPAND|wxALL, 10)
 
         self.SetSizer(sizer)
-        self.SetAutoLayout(true)
+        self.SetAutoLayout(True)
 
 
     def __del__(self):
 
 
     def __del__(self):
@@ -70,14 +70,14 @@ class TestPanel(wxPanel):
 
         self.process = wxProcess(self)
         self.process.Redirect();
 
         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.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()
 
 
         self.inp.SetFocus()
 
 
@@ -99,11 +99,7 @@ class TestPanel(wxPanel):
         if self.process is not None:
             stream = self.process.GetInputStream()
 
         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)
 
                 text = stream.read()
                 self.out.AppendText(text)
 
@@ -113,17 +109,17 @@ class TestPanel(wxPanel):
                        (evt.GetPid(), evt.GetExitCode()))
 
         stream = self.process.GetInputStream()
                        (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
             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)
 
 
 #----------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------
@@ -156,3 +152,12 @@ child process to exit its main loop.
 
 </body><html>
 """
 
 </body><html>
 """
+
+
+
+
+
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])