]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Frame.py
Regenerate to add the new file toucan.png.
[wxWidgets.git] / wxPython / demo / Frame.py
1
2 import wx
3
4 #---------------------------------------------------------------------------
5
6 class MyFrame(wx.Frame):
7 def __init__(
8 self, parent, ID, title, pos=wx.DefaultPosition,
9 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
10 ):
11
12 wx.Frame.__init__(self, parent, ID, title, pos, size, style)
13 panel = wx.Panel(self, -1)
14
15 button = wx.Button(panel, 1003, "Close Me")
16 button.SetPosition((15, 15))
17 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
18 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
19
20
21 def OnCloseMe(self, event):
22 self.Close(True)
23
24 def OnCloseWindow(self, event):
25 self.Destroy()
26
27 #---------------------------------------------------------------------------
28
29 class TestPanel(wx.Panel):
30 def __init__(self, parent, log):
31 self.log = log
32 wx.Panel.__init__(self, parent, -1)
33
34 b = wx.Button(self, -1, "Create and Show a Frame", (50,50))
35 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
36
37
38 def OnButton(self, evt):
39 win = MyFrame(self, -1, "This is a wx.Frame", size=(350, 200),
40 style = wx.DEFAULT_FRAME_STYLE)
41 win.Show(True)
42
43
44
45 #---------------------------------------------------------------------------
46
47
48 def runTest(frame, nb, log):
49 win = TestPanel(nb, log)
50 return win
51
52
53 #---------------------------------------------------------------------------
54
55
56 overview = """\
57 A Frame is a window whose size and position can (usually) be changed by
58 the user. It usually has thick borders and a title bar, and can optionally
59 contain a menu bar, toolbar and status bar. A frame can contain any window
60 that is not a Frame or Dialog. It is one of the most fundamental of the
61 wxWindows components.
62
63 A Frame that has a status bar and toolbar created via the
64 <code>CreateStatusBar</code> / <code>CreateToolBar</code> functions manages
65 these windows, and adjusts the value returned by <code>GetClientSize</code>
66 to reflect the remaining size available to application windows.
67
68 By itself, a Frame is not too useful, but with the addition of Panels and
69 other child objects, it encompasses the framework around which most user
70 interfaces are constructed.
71
72 If you plan on using Sizers and auto-layout features, be aware that the Frame
73 class lacks the ability to handle these features unless it contains a Panel.
74 The Panel has all the necessary functionality to both control the size of
75 child components, and also communicate that information in a useful way to
76 the Frame itself.
77 """
78
79
80 if __name__ == '__main__':
81 import sys,os
82 import run
83 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
84