]>
Commit | Line | Data |
---|---|---|
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 | self.log = log | |
19 | ||
20 | # Now make a bunch of panels for the choice book | |
21 | count = 1 | |
22 | for txt in pageTexts: | |
23 | win = wx.Panel(self) | |
24 | if count == 1: | |
25 | st = wx.StaticText(win, -1, | |
26 | "wx.Choicebook is yet another way to switch between 'page' windows", | |
27 | (10, 10)) | |
28 | else: | |
29 | st = wx.StaticText(win, -1, "Page: %d" % count, (10,10)) | |
30 | count += 1 | |
31 | ||
32 | self.AddPage(win, txt) | |
33 | ||
34 | self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged) | |
35 | self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging) | |
36 | ||
37 | ||
38 | def OnPageChanged(self, event): | |
39 | old = event.GetOldSelection() | |
40 | new = event.GetSelection() | |
41 | sel = self.GetSelection() | |
42 | self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
43 | event.Skip() | |
44 | ||
45 | def OnPageChanging(self, event): | |
46 | old = event.GetOldSelection() | |
47 | new = event.GetSelection() | |
48 | sel = self.GetSelection() | |
49 | self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
50 | event.Skip() | |
51 | ||
52 | #---------------------------------------------------------------------------- | |
53 | ||
54 | def runTest(frame, nb, log): | |
55 | testWin = TestCB(nb, -1, log) | |
56 | return testWin | |
57 | ||
58 | #---------------------------------------------------------------------------- | |
59 | ||
60 | ||
61 | overview = """\ | |
62 | <html><body> | |
63 | <h2>wx.Choicebook</h2> | |
64 | <p> | |
65 | ||
66 | This class is a control similar to a notebook control, but uses a | |
67 | wx.Choice to manage the selection of the pages. | |
68 | ||
69 | """ | |
70 | ||
71 | ||
72 | ||
73 | if __name__ == '__main__': | |
74 | import sys,os | |
75 | import run | |
76 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
77 | ||
78 | ||
79 |