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