]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/Frame.py
The great wxVScrolledWindow refactoring: allow using it both horizontal and
[wxWidgets.git] / wxPython / demo / Frame.py
... / ...
CommitLineData
1
2import wx
3
4#---------------------------------------------------------------------------
5
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 ):
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
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
48def runTest(frame, nb, log):
49 win = TestPanel(nb, log)
50 return win
51
52
53#---------------------------------------------------------------------------
54
55
56overview = """\
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.
77"""
78
79
80if __name__ == '__main__':
81 import sys,os
82 import run
83 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
84