]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Choicebook.py
wxDEFAULT_STATUSBAR_STYLE
[wxWidgets.git] / wxPython / demo / Choicebook.py
1
2 import wx
3
4 #----------------------------------------------------------------------------
5
6 pageTexts = [ "Yet",
7 "Another",
8 "Way",
9 "To",
10 "Select",
11 "Pages"
12 ]
13
14
15 class TestCB(wx.Choicebook):
16 def __init__(self, parent, id, log):
17 wx.Choicebook.__init__(self, parent, id
18 )
19 self.log = log
20
21 # Now make a bunch of panels for the choice book
22 count = 1
23 for txt in pageTexts:
24 win = wx.Panel(self)
25 if count == 1:
26 st = wx.StaticText(win, -1,
27 "wx.Choicebook is yet another way to switch between 'page' windows",
28 (10, 10))
29 else:
30 st = wx.StaticText(win, -1, "Page: %d" % count, (10,10))
31 count += 1
32
33 self.AddPage(win, txt)
34
35 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
36 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
37
38
39 def OnPageChanged(self, event):
40 old = event.GetOldSelection()
41 new = event.GetSelection()
42 sel = self.GetSelection()
43 self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
44 event.Skip()
45
46 def OnPageChanging(self, event):
47 old = event.GetOldSelection()
48 new = event.GetSelection()
49 sel = self.GetSelection()
50 self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
51 event.Skip()
52
53 #----------------------------------------------------------------------------
54
55 def runTest(frame, nb, log):
56 testWin = TestCB(nb, -1, log)
57 return testWin
58
59 #----------------------------------------------------------------------------
60
61
62 overview = """\
63 <html><body>
64 <h2>wx.Choicebook</h2>
65 <p>
66
67 This class is a control similar to a notebook control, but uses a
68 wx.Choice to manage the selection of the pages.
69
70 """
71
72
73
74 if __name__ == '__main__':
75 import sys,os
76 import run
77 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
78
79
80