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