]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Frame.py
4 #---------------------------------------------------------------------------
6 class MyFrame(wx
.Frame
):
8 self
, parent
, ID
, title
, pos
=wx
.DefaultPosition
,
9 size
=wx
.DefaultSize
, style
=wx
.DEFAULT_FRAME_STYLE
12 wx
.Frame
.__init
__(self
, parent
, ID
, title
, pos
, size
, style
)
13 panel
= wx
.Panel(self
, -1)
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
)
21 def OnCloseMe(self
, event
):
24 def OnCloseWindow(self
, event
):
27 #---------------------------------------------------------------------------
29 class TestPanel(wx
.Panel
):
30 def __init__(self
, parent
, log
):
32 wx
.Panel
.__init
__(self
, parent
, -1)
34 b
= wx
.Button(self
, -1, "Create and Show a Frame", (50,50))
35 self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
)
38 def OnButton(self
, evt
):
39 win
= MyFrame(self
, -1, "This is a wx.Frame", size
=(350, 200),
40 style
= wx
.DEFAULT_FRAME_STYLE
)
45 #---------------------------------------------------------------------------
48 def runTest(frame
, nb
, log
):
49 win
= TestPanel(nb
, log
)
53 #---------------------------------------------------------------------------
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
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.
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.
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
80 if __name__
== '__main__':
83 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])