2 from wxPython
.wx
import *
3 from wxPython
.lib
.infoframe
import *
5 #----------------------------------------------------------------------
7 class MyFrame(wxFrame
):
8 def __init__(self
,output
):
9 wxFrame
.__init
__(self
,None,-1,"Close me...",size
=(300,100))
13 menu
.Append(mID
,"&Enable output","Display output frame")
14 EVT_MENU(self
,mID
,output
.EnableOutput
)
16 menu
.Append(mID
,"&Disable output","Close output frame")
17 EVT_MENU(self
,mID
,output
.DisableOutput
)
18 menubar
.Append(menu
,"&Output")
19 self
.SetMenuBar(menubar
)
20 output
.SetParent(self
)
21 output
.SetOtherMenuBar(menubar
,menuname
="Output")
22 EVT_CLOSE(self
,self
.OnClose
)
23 EVT_TIMER(self
, -1, self
.OnTimer
)
25 self
.timer
= wxTimer(self
, -1)
26 self
.timer
.Start(1000)
28 self
.save_stdout
= sys
.stdout
29 sys
.stdout
= self
.output
= output
32 def OnClose(self
,event
):
33 sys
.stdout
= self
.save_stdout
39 def OnTimer(self
, evt
):
40 print "This was printed with \"print\""
43 #----------------------------------------------------------------------
45 from wxPython
.lib
import infoframe
46 overview
= infoframe
.__doc
__
48 def runTest(frame
, nb
, log
):
50 This method is used by the wxPython Demo Framework for integrating
51 this demo with the rest.
53 win
= MyFrame(wxPyInformationalMessagesFrame())
57 #----------------------------------------------------------------------
59 if __name__
== "__main__":
60 ## class MyFrame(wxFrame):
61 ## def __init__(self,output):
62 ## wxFrame.__init__(self,None,-1,"Close me...",size=(300,100))
63 ## EVT_CLOSE(self,self.OnClose)
64 ## menubar = wxMenuBar()
67 ## menu.Append(mID,"&Enable output","Display output frame")
68 ## EVT_MENU(self,mID,output.EnableOutput)
70 ## menu.Append(mID,"&Disable output","Close output frame")
71 ## EVT_MENU(self,mID,output.DisableOutput)
72 ## menubar.Append(menu,"&Output")
73 ## self.SetMenuBar(menubar)
74 ## output.SetOtherMenuBar(menubar,menuname="Output")
76 ## def OnClose(self,event):
77 ## if isinstance(sys.stdout,wxPyInformationalMessagesFrame):
82 outputWindowClass
= wxPyInformationalMessagesFrame
84 frame
= MyFrame(self
.stdioWin
)
86 self
.SetTopWindow(frame
)
87 if isinstance(sys
.stdout
,wxPyInformationalMessagesFrame
):
88 sys
.stdout
.SetParent(frame
)
89 #self.redirectStdio(None)# this is done automatically
90 # by the MyApp(1) call below