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