]>
Commit | Line | Data |
---|---|---|
cf694132 RD |
1 | |
2 | from wxPython.wx import * | |
f0261a72 | 3 | |
cf694132 | 4 | import ColorPanel |
f6bcfd97 | 5 | import GridSimple |
f0261a72 RD |
6 | import wxListCtrl |
7 | import wxScrolledWindow | |
1e4a197e | 8 | import images |
cf694132 | 9 | |
dfef5d51 RD |
10 | import sys |
11 | ||
cf694132 RD |
12 | #---------------------------------------------------------------------------- |
13 | ||
eec92d76 RD |
14 | class TestNB(wxNotebook): |
15 | def __init__(self, parent, id, log): | |
1e4a197e | 16 | wxNotebook.__init__(self, parent, id, style= |
1fded56b | 17 | #wxNB_TOP |
1e4a197e RD |
18 | wxNB_BOTTOM |
19 | #wxNB_LEFT | |
20 | #wxNB_RIGHT | |
21 | ) | |
eec92d76 | 22 | self.log = log |
cf694132 | 23 | |
afcb7fb8 | 24 | win = self.makeColorPanel(wxBLUE) |
eec92d76 | 25 | self.AddPage(win, "Blue") |
afcb7fb8 | 26 | st = wxStaticText(win.win, -1, |
eec92d76 | 27 | "You can put nearly any type of window here,\n" |
eb0f373c RD |
28 | "and if the platform supports it then the\n" |
29 | "tabs can be on any side of the notebook.", | |
eec92d76 RD |
30 | wxPoint(10, 10)) |
31 | st.SetForegroundColour(wxWHITE) | |
32 | st.SetBackgroundColour(wxBLUE) | |
cf694132 | 33 | |
1e4a197e RD |
34 | # Show how to put an image on one of the notebook tabs, |
35 | # first make the image list: | |
36 | il = wxImageList(16, 16) | |
37 | idx1 = il.Add(images.getSmilesBitmap()) | |
38 | self.AssignImageList(il) | |
39 | ||
40 | # now put an image on the first tab we just created: | |
41 | self.SetPageImage(0, idx1) | |
42 | ||
43 | ||
afcb7fb8 | 44 | win = self.makeColorPanel(wxRED) |
eec92d76 | 45 | self.AddPage(win, "Red") |
cf694132 | 46 | |
eec92d76 RD |
47 | win = wxScrolledWindow.MyCanvas(self) |
48 | self.AddPage(win, 'ScrolledWindow') | |
cf694132 | 49 | |
afcb7fb8 | 50 | win = self.makeColorPanel(wxGREEN) |
eec92d76 | 51 | self.AddPage(win, "Green") |
f0261a72 | 52 | |
f6bcfd97 | 53 | win = GridSimple.SimpleGrid(self, log) |
eec92d76 | 54 | self.AddPage(win, "Grid") |
cf694132 | 55 | |
eec92d76 RD |
56 | win = wxListCtrl.TestListCtrlPanel(self, log) |
57 | self.AddPage(win, 'List') | |
f0261a72 | 58 | |
afcb7fb8 | 59 | win = self.makeColorPanel(wxCYAN) |
eec92d76 | 60 | self.AddPage(win, "Cyan") |
f0261a72 | 61 | |
1fded56b RD |
62 | ## win = self.makeColorPanel(wxWHITE) |
63 | ## self.AddPage(win, "White") | |
cf694132 | 64 | |
1fded56b RD |
65 | ## win = self.makeColorPanel(wxBLACK) |
66 | ## self.AddPage(win, "Black") | |
cf694132 | 67 | |
afcb7fb8 | 68 | win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE')) |
eec92d76 | 69 | self.AddPage(win, "MIDNIGHT BLUE") |
cf694132 | 70 | |
afcb7fb8 | 71 | win = self.makeColorPanel(wxNamedColour('INDIAN RED')) |
eec92d76 | 72 | self.AddPage(win, "INDIAN RED") |
cf694132 | 73 | |
eec92d76 | 74 | EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged) |
3bd1e033 | 75 | EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging) |
cf694132 | 76 | |
cf694132 | 77 | |
afcb7fb8 RD |
78 | def makeColorPanel(self, color): |
79 | p = wxPanel(self, -1) | |
80 | win = ColorPanel.ColoredPanel(p, color) | |
81 | p.win = win | |
82 | def OnCPSize(evt, win=win): | |
83 | win.SetSize(evt.GetSize()) | |
84 | EVT_SIZE(p, OnCPSize) | |
85 | return p | |
86 | ||
87 | ||
eec92d76 | 88 | def OnPageChanged(self, event): |
3bd1e033 RD |
89 | old = event.GetOldSelection() |
90 | new = event.GetSelection() | |
1fded56b RD |
91 | sel = self.GetSelection() |
92 | self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
3bd1e033 RD |
93 | event.Skip() |
94 | ||
95 | def OnPageChanging(self, event): | |
96 | old = event.GetOldSelection() | |
97 | new = event.GetSelection() | |
1fded56b RD |
98 | sel = self.GetSelection() |
99 | self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
eec92d76 | 100 | event.Skip() |
cf694132 | 101 | |
eec92d76 | 102 | #---------------------------------------------------------------------------- |
cf694132 | 103 | |
eec92d76 RD |
104 | def runTest(frame, nb, log): |
105 | testWin = TestNB(nb, -1, log) | |
106 | return testWin | |
107 | ||
108 | #---------------------------------------------------------------------------- | |
cf694132 RD |
109 | |
110 | ||
111 | ||
112 | ||
1e4a197e RD |
113 | overview = """\ |
114 | <html><body> | |
115 | <h2>wxNotebook</h2> | |
116 | <p> | |
117 | This class represents a notebook control, which manages multiple | |
118 | windows with associated tabs. | |
119 | <p> | |
120 | To use the class, create a wxNotebook object and call AddPage or | |
121 | InsertPage, passing a window to be used as the page. Do not explicitly | |
122 | delete the window for a page that is currently managed by wxNotebook. | |
cf694132 | 123 | |
1e4a197e | 124 | """ |
cf694132 RD |
125 | |
126 | ||
127 | ||
1e4a197e RD |
128 | if __name__ == '__main__': |
129 | import sys,os | |
130 | import run | |
131 | run.main(['', os.path.basename(sys.argv[0])]) | |
cf694132 RD |
132 | |
133 | ||
134 | ||
135 | ||
dfef5d51 | 136 |