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