-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_ch2.py
85 lines (68 loc) · 2.78 KB
/
gui_ch2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bi/env python
# -*- coding: cp1252 -*-
##If wxPython is controlling the standard streams, then text sent to the streams via
##any mechanism—including a print statement or a system traceback—is redirected
##to a separate wxPython frame. Text sent to the streams before the wxPython application
##begins or after it ends is, of course, processed normally.
##
##If the redirect parameter is True, then the second parameter, filename,
##can also be set. If so, output is redirected to a file with that name, rather than to
##the wxPython frame.
##will cause all the redirected lines to be sent to a file named output. The App
##__init_ and after MainLoop messages will still be sent to the console, however,
##because they occur outside of the time period where the wx.App object has control
##of the streams.
import wx
import sys
import images
class Frame(wx.Frame):
def __init__(self,parent, id, title):
print "Frame __init__"
print wx.ID_LOWEST, wx.ID_HIGHEST
wx.Frame.__init__(self, parent, id, title, size=(300,100))
#added close button
panel=wx.Panel(self)
statusBar=self.CreateStatusBar()
toolBar=self.CreateToolBar()
toolBar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), "New", "Long helo for 'New'")
toolBar.Realize()
menuBar=wx.MenuBar()
menu1=wx.Menu()
menuBar.Append(menu1, "File")
menu2=wx.Menu()
menu2.Append(wx.NewId(), "Copy", "copy in the status bar")
menu2.Append(wx.NewId(), "Cut", "cut")
menu2.AppendSeparator()
menu2.Append(wx.NewId(), "Options...", "Display Options")
menuBar.Append(menu2, "E&dit")
self.SetMenuBar(menuBar)
button=wx.Button(panel, label="close", pos=(125,10), size=(50,50))
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCloseMe(self, event):
self.Close(True)
def OnCloseWindow(self, event):
self.Destroy()
class App(wx.App):
def __init__(self, redirect, filename=None):
print "App __init__"
wx.App.__init__(self, redirect, filename)
#application to continue after the last window
#closes
## self.SetExitOnFrameDelete(False)
def OnInit(self):
print "OnInit"
self.frame=Frame(parent=None, id=-1, title='Startup')
self.frame.Show()
print self.frame.GetId()
self.SetTopWindow(self.frame)
print >> sys.stderr, "A pretend error message"
return True
def OnExit(self):
print "onexit"
if __name__=="__main__":
app=App(redirect=False)
print "before MainLoop"
app.MainLoop()
print "After MainLoop"
##Gondolom ez akkor lehet hasznos ha peldaul mar exe van belole es nincsen tobbe konzol.