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