]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Frame.py
reSWIGged
[wxWidgets.git] / wxPython / demo / Frame.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132
RD
3
4#---------------------------------------------------------------------------
5
8fa876ca
RD
6class MyFrame(wx.Frame):
7 def __init__(
8 self, parent, ID, title, pos=wx.DefaultPosition,
9 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
10 ):
cf694132 11
8fa876ca
RD
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)
f6bcfd97 19
cf694132
RD
20
21 def OnCloseMe(self, event):
1e4a197e 22 self.Close(True)
cf694132
RD
23
24 def OnCloseWindow(self, event):
25 self.Destroy()
26
27#---------------------------------------------------------------------------
28
34a544a6
RD
29class 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
cf694132 48def runTest(frame, nb, log):
34a544a6
RD
49 win = TestPanel(nb, log)
50 return win
cf694132
RD
51
52
53#---------------------------------------------------------------------------
54
55
cf694132 56overview = """\
8fa876ca
RD
57A Frame is a window whose size and position can (usually) be changed by
58the user. It usually has thick borders and a title bar, and can optionally
59contain a menu bar, toolbar and status bar. A frame can contain any window
60that is not a Frame or Dialog. It is one of the most fundamental of the
61wxWindows components.
62
63A Frame that has a status bar and toolbar created via the
64<code>CreateStatusBar</code> / <code>CreateToolBar</code> functions manages
65these windows, and adjusts the value returned by <code>GetClientSize</code>
66to reflect the remaining size available to application windows.
67
68By itself, a Frame is not too useful, but with the addition of Panels and
69other child objects, it encompasses the framework around which most user
70interfaces are constructed.
71
72If you plan on using Sizers and auto-layout features, be aware that the Frame
73class lacks the ability to handle these features unless it contains a Panel.
74The Panel has all the necessary functionality to both control the size of
75child components, and also communicate that information in a useful way to
76the Frame itself.
cf694132 77"""
1fded56b
RD
78
79
1fded56b
RD
80if __name__ == '__main__':
81 import sys,os
82 import run
8eca4fef 83 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 84