From c856d372d1d4f4223511d2988298ba3d503222a4 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 15 Mar 2001 00:33:33 +0000 Subject: [PATCH 1/1] fixed the automatic sys.stdout/sys.stderr to window redirection in wxApp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_extras.py | 13 ++++++------- wxPython/src/msw/wx.cpp | 8 ++++++++ wxPython/src/msw/wx.py | 13 ++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/wxPython/src/_extras.py b/wxPython/src/_extras.py index ebc8ca9afb..5e16b1f7a4 100644 --- a/wxPython/src/_extras.py +++ b/wxPython/src/_extras.py @@ -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() + #---------------------------------------------------------------------------- diff --git a/wxPython/src/msw/wx.cpp b/wxPython/src/msw/wx.cpp index 9e31e511cf..250ddf2a18 100644 --- a/wxPython/src/msw/wx.cpp +++ b/wxPython/src/msw/wx.cpp @@ -1844,6 +1844,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxDataObject","_class_wxDataObject",0}, { "_class_wxPyFontEnumerator","_wxPyFontEnumerator",0}, { "_wxStaticBox","_class_wxStaticBox",0}, + { "_wxColourDatabase","_class_wxColourDatabase",0}, { "_wxPyDataObjectSimple","_class_wxPyDataObjectSimple",0}, { "_wxPyDropSource","_class_wxPyDropSource",0}, { "_wxChoice","_class_wxChoice",0}, @@ -1957,6 +1958,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_class_wxZipFSHandler","_wxZipFSHandler",0}, { "_char","_wxChar",0}, { "_wxBitmap","_class_wxBitmap",0}, + { "_wxPenList","_class_wxPenList",0}, { "_wxTaskBarIcon","_class_wxTaskBarIcon",0}, { "_wxPrintDialog","_class_wxPrintDialog",0}, { "_wxWindowDC","_class_wxWindowDC",0}, @@ -1984,6 +1986,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_class_wxToolBar","_wxToolBar",0}, { "_wxDropTarget","_class_wxDropTarget",0}, { "_class_wxStaticLine","_wxStaticLine",0}, + { "_class_wxColourDatabase","_wxColourDatabase",0}, { "_wxScrollEvent","_class_wxScrollEvent",0}, { "_wxToolBarToolBase","_class_wxToolBarToolBase",0}, { "_wxCalculateLayoutEvent","_class_wxCalculateLayoutEvent",0}, @@ -2012,9 +2015,11 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxScrollWinEvent","_class_wxScrollWinEvent",0}, { "_wxGenericDragImage","_class_wxGenericDragImage",0}, { "_class_wxProgressDialog","_wxProgressDialog",0}, + { "_class_wxBrushList","_wxBrushList",0}, { "_wxQueryNewPaletteEvent","_class_wxQueryNewPaletteEvent",0}, { "_wxPyInputStream","_class_wxPyInputStream",0}, { "_wxPyApp","_class_wxPyApp",0}, + { "_class_wxPenList","_wxPenList",0}, { "_class_wxWindowCreateEvent","_wxWindowCreateEvent",0}, { "_class_wxOutputStream","_wxOutputStream",0}, { "_wxLogTextCtrl","_class_wxLogTextCtrl",0}, @@ -2074,6 +2079,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_class_wxCloseEvent","_wxCloseEvent",0}, { "_wxSashEvent","_class_wxSashEvent",0}, { "_wxBusyInfo","_class_wxBusyInfo",0}, + { "_wxFontList","_class_wxFontList",0}, { "_class_wxMenuEvent","_wxMenuEvent",0}, { "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0}, { "_wxJoystick","_class_wxJoystick",0}, @@ -2255,11 +2261,13 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxGauge","_class_wxGauge",0}, { "_class_wxCheckListBox","_wxCheckListBox",0}, { "_class_wxBusyInfo","_wxBusyInfo",0}, + { "_class_wxFontList","_wxFontList",0}, { "_class_wxJoystick","_wxJoystick",0}, { "_class_wxCommandEvent","_wxCommandEvent",0}, { "_class_wxClientDC","_wxClientDC",0}, { "_class_wxSizeEvent","_wxSizeEvent",0}, { "_class_wxListCtrl","_wxListCtrl",0}, + { "_wxBrushList","_class_wxBrushList",0}, { "_wxCustomDataObject","_class_wxCustomDataObject",0}, { "_class_wxLogNull","_wxLogNull",0}, { "_class_wxSize","_wxSize",0}, diff --git a/wxPython/src/msw/wx.py b/wxPython/src/msw/wx.py index cd6c29be4c..f960b79d8a 100644 --- a/wxPython/src/msw/wx.py +++ b/wxPython/src/msw/wx.py @@ -1526,12 +1526,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): @@ -1545,7 +1547,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) @@ -1559,9 +1561,7 @@ class wxPyOnDemandOutputWindow: def close(self): if self.frame != None: - self.frame.Destroy() - self.frame = None - self.text = None + self.frame.Close() @@ -1595,7 +1595,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) @@ -1609,12 +1608,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() + #---------------------------------------------------------------------------- -- 2.45.2