]> git.saurik.com Git - wxWidgets.git/blame - wxPython/misc/notebooktest.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / misc / notebooktest.py
CommitLineData
7d9f33e2
RD
1
2import wx
3
4
5class TestNotebook(wx.Notebook):
6 def __init__(self, parent, ID=-1):
7 wx.Notebook.__init__(self, parent, ID)
8
9 # page 1
10 # just a panel with a small fixed size
11 p = wx.Panel(self, size=(50,50))
12 self.AddPage(p, "page 1")
13
14 # page 2
15 # a medium sized panel with manually layed out controls
16 p = wx.Panel(self)
17 b = wx.Button(p, -1, "a button", (20,20))
18 b = wx.Button(p, -1, "another button", (80,80))
19 b = wx.Button(p, -1, "and yet another button", (140,140))
20 b.Bind(wx.EVT_BUTTON, self.ShowBestSizes)
21 self.AddPage(p, "page 2")
22
23 # page 3
24 # a larger panel with lots of controls in a sizer.
25 text = "one two buckle my shoe three four shut the door "\
26 "five six pick up sticks seven eight lay them straight "\
27 "nine ten big fat hen"
28 p = wx.Panel(self)
29 fgs = wx.FlexGridSizer(cols=4, vgap=5, hgap=5)
30 for word in text.split():
31 label = wx.StaticText(p, -1, word+":")
32 tc = wx.TextCtrl(p, -1, "", size=(120,-1))
33 fgs.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10)
34 fgs.Add(tc, flag=wx.RIGHT, border=10)
35 box = wx.BoxSizer()
36 box.Add(fgs, 1, wx.EXPAND|wx.ALL, 10)
37 p.SetSizer(box)
38 self.AddPage(p, "page 3")
39
40
41 # show the best size of each page
42 def ShowBestSizes(self, evt):
43 for num in range(self.GetPageCount()):
44 page = self.GetPage(num)
45 print page.GetBestSize()
46
47
48if __name__ == '__main__':
49 app = wx.PySimpleApp()
50 f = wx.Frame(None, -1, "Notebook Test")
51 nb = TestNotebook(f)
52 s = wx.BoxSizer()
53 s.Add(nb) # notebook is added directly to the sizer
54 f.SetSizer(s)
55 s.Fit(f) # sizer calculates layout to set frame size
56 f.Show()
57 app.MainLoop()
58