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