X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c3b4aae47ec7ce70683df1c502a683cb9b0841c..5444f3a9445fe30633aef827154ed57656273a35:/wxPython/src/_app_ex.py?ds=sidebyside diff --git a/wxPython/src/_app_ex.py b/wxPython/src/_app_ex.py index de885de22e..f3246fbcc6 100644 --- a/wxPython/src/_app_ex.py +++ b/wxPython/src/_app_ex.py @@ -21,13 +21,21 @@ class PyOnDemandOutputWindow: def CreateOutputWindow(self, st): self.frame = wx.Frame(self.parent, -1, self.title, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE) - self.text = wxTextCtrl(self.frame, -1, "", - style = wx.TE_MULTILINE | wx.TE_READONLY) + self.text = wx.TextCtrl(self.frame, -1, "", + style = wx.TE_MULTILINE | wx.TE_READONLY) + self.text.AppendText(st) self.frame.SetSize((450, 300)) self.frame.Show(True) EVT_CLOSE(self.frame, self.OnCloseWindow) + def OnCloseWindow(self, event): + if self.frame is not None: + self.frame.Destroy() + self.frame = None + self.text = None + + # These methods provide the file-like output behaviour. def write(self, text): """ @@ -52,11 +60,6 @@ class PyOnDemandOutputWindow: wx.CallAfter(self.frame.Close) - def OnCloseWindow(self, event): - if self.frame is not None: - self.frame.Destroy() - self.frame = None - self.text = None #---------------------------------------------------------------------- @@ -118,17 +121,20 @@ your Mac.""" def SetTopWindow(self, frame): + """Set the \"main\" top level window""" if self.stdioWin: self.stdioWin.SetParent(frame) wx.PyApp.SetTopWindow(self, frame) def MainLoop(self): + """Execute the main GUI event loop""" wx.PyApp.MainLoop(self) self.RestoreStdio() - def RedirectStdio(self, filename): + def RedirectStdio(self, filename=None): + """Redirect sys.stdout and sys.stderr to a file or a popup window.""" if filename: _sys.stdout = _sys.stderr = open(filename, 'a') else: @@ -177,7 +183,7 @@ class PyWidgetTester(wx.App): wx.App.__init__(self, 0) def OnInit(self): - self.frame = wxFrame(None, -1, "Widget Tester", pos=(0,0), size=self.size) + self.frame = wx.Frame(None, -1, "Widget Tester", pos=(0,0), size=self.size) self.SetTopWindow(self.frame) return True