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