]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_extras.py
OwnerDrawn updates
[wxWidgets.git] / wxPython / src / _extras.py
index ebc8ca9afb79ec7ae8620bc6e2905ed623649ef6..5e16b1f7a4278c8cbd95ba5edada622933901be7 100644 (file)
@@ -705,12 +705,14 @@ def wxPyTypeCast(obj, typeStr):
     return theObj
 
 
+#----------------------------------------------------------------------
 #----------------------------------------------------------------------
 
 class wxPyOnDemandOutputWindow:
     def __init__(self, title = "wxPython: stdout/stderr"):
         self.frame  = None
         self.title  = title
+        self.parent = None
 
 
     def SetParent(self, parent):
@@ -724,7 +726,7 @@ class wxPyOnDemandOutputWindow:
         self.text  = None
 
 
-    # this provides the file-like behaviour
+    # this provides the file-like output behaviour
     def write(self, str):
         if not self.frame:
             self.frame = wxFrame(self.parent, -1, self.title)
@@ -738,9 +740,7 @@ class wxPyOnDemandOutputWindow:
 
     def close(self):
         if self.frame != None:
-            self.frame.Destroy()
-        self.frame = None
-        self.text  = None
+            self.frame.Close()
 
 
 
@@ -774,7 +774,6 @@ class wxApp(wxPyApp):
     def SetTopWindow(self, frame):
         if self.stdioWin:
             self.stdioWin.SetParent(frame)
-            sys.stderr = sys.stdout = self.stdioWin
         wxPyApp.SetTopWindow(self, frame)
 
 
@@ -788,12 +787,12 @@ class wxApp(wxPyApp):
             sys.stdout = sys.stderr = open(filename, 'a')
         else:
             self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow
+            sys.stdout = sys.stderr = self.stdioWin
 
 
     def RestoreStdio(self):
         sys.stdout, sys.stderr = self.saveStdio
-        if self.stdioWin != None:
-            self.stdioWin.close()
+
 
 #----------------------------------------------------------------------------