]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/infoframe.py
compilation error fix (trailing comma in an enum)
[wxWidgets.git] / wxPython / demo / infoframe.py
CommitLineData
03a2c062
RD
1
2from wxPython.wx import *
3from wxPython.lib.infoframe import *
4
5#----------------------------------------------------------------------
6
7class MyFrame(wxFrame):
8 def __init__(self,output):
9 wxFrame.__init__(self,None,-1,"Close me...",size=(300,100))
10 menubar = wxMenuBar()
11 menu = wxMenu()
12 mID = NewId()
13 menu.Append(mID,"&Enable output","Display output frame")
14 EVT_MENU(self,mID,output.EnableOutput)
15 mID = NewId()
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)
24
25 self.timer = wxTimer(self, -1)
26 self.timer.Start(1000)
27
28 self.save_stdout = sys.stdout
29 sys.stdout = self.output = output
30 print "Hello!"
31
32 def OnClose(self,event):
33 sys.stdout = self.save_stdout
34 self.output.close()
35 self.timer.Stop()
36 self.timer = None
37 self.Destroy()
38
39 def OnTimer(self, evt):
40 print "This was printed with \"print\""
41
42
43#----------------------------------------------------------------------
44
45from wxPython.lib import infoframe
46overview = infoframe.__doc__
47
48def runTest(frame, nb, log):
49 """
50 This method is used by the wxPython Demo Framework for integrating
51 this demo with the rest.
52 """
53 win = MyFrame(wxPyInformationalMessagesFrame())
54 frame.otherWin = win
55 win.Show(1)
56
57#----------------------------------------------------------------------
58
59if __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()
65## menu = wxMenu()
66## mID = NewId()
67## menu.Append(mID,"&Enable output","Display output frame")
68## EVT_MENU(self,mID,output.EnableOutput)
69## mID = NewId()
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")
75
76## def OnClose(self,event):
77## if isinstance(sys.stdout,wxPyInformationalMessagesFrame):
78## sys.stdout.close()
79## self.Destroy()
80
81 class MyApp(wxApp):
82 outputWindowClass = wxPyInformationalMessagesFrame
83 def OnInit(self):
84 frame = MyFrame(self.stdioWin)
85 frame.Show(TRUE)
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
91 print "Starting.\n",
92 return true
93
94 app = MyApp(1)
95 app.MainLoop()