]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxListbook.py
Added listbook demo and also some other demo tweaks
[wxWidgets.git] / wxPython / demo / wxListbook.py
1
2 from wxPython.wx import *
3
4 import ColorPanel
5 import GridSimple
6 import wxListCtrl
7 import wxScrolledWindow
8 import images
9
10 import sys
11
12 #----------------------------------------------------------------------------
13
14 class TestLB(wxListbook):
15 def __init__(self, parent, id, log):
16 wxListbook.__init__(self, parent, id, style=
17 wxLB_DEFAULT
18 #wxLB_TOP
19 #wxLB_BOTTOM
20 #wxLB_LEFT
21 #wxLB_RIGHT
22 )
23 self.log = log
24
25 win = self.makeColorPanel(wxBLUE)
26 self.AddPage(win, "Blue")
27 st = wxStaticText(win.win, -1,
28 "You can put nearly any type of window here,\n"
29 "and if the platform supports it then the\n"
30 "tabs can be on any side of the notebook.",
31 wxPoint(10, 10))
32 st.SetForegroundColour(wxWHITE)
33 st.SetBackgroundColour(wxBLUE)
34
35 # Show how to put an image on one of the notebook tabs,
36 # first make the image list:
37 il = wxImageList(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(wxRED)
46 self.AddPage(win, "Red")
47
48 win = wxScrolledWindow.MyCanvas(self)
49 self.AddPage(win, 'ScrolledWindow')
50
51 win = self.makeColorPanel(wxGREEN)
52 self.AddPage(win, "Green")
53
54 win = GridSimple.SimpleGrid(self, log)
55 self.AddPage(win, "Grid")
56
57 win = wxListCtrl.TestListCtrlPanel(self, log)
58 self.AddPage(win, 'List')
59
60 win = self.makeColorPanel(wxCYAN)
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(wxNamedColour('MIDNIGHT BLUE'))
70 self.AddPage(win, "MIDNIGHT BLUE")
71
72 win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
73 self.AddPage(win, "INDIAN RED")
74
75 EVT_LISTBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
76 EVT_LISTBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
77
78
79 def makeColorPanel(self, color):
80 p = wxPanel(self, -1)
81 win = ColorPanel.ColoredPanel(p, color)
82 p.win = win
83 def OnCPSize(evt, win=win):
84 win.SetSize(evt.GetSize())
85 EVT_SIZE(p, OnCPSize)
86 return p
87
88
89 def OnPageChanged(self, event):
90 old = event.GetOldSelection()
91 new = event.GetSelection()
92 sel = self.GetSelection()
93 self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
94 event.Skip()
95
96 def OnPageChanging(self, event):
97 old = event.GetOldSelection()
98 new = event.GetSelection()
99 sel = self.GetSelection()
100 self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
101 event.Skip()
102
103 #----------------------------------------------------------------------------
104
105 def runTest(frame, nb, log):
106 testWin = TestLB(nb, -1, log)
107 return testWin
108
109 #----------------------------------------------------------------------------
110
111
112
113
114 overview = """\
115 <html><body>
116 <h2>wxListbook</h2>
117 <p>
118 This class is a control similar to a notebook control, but with a
119 wxListCtrl instead of a set of tabs.
120
121 """
122
123
124
125 if __name__ == '__main__':
126 import sys,os
127 import run
128 run.main(['', os.path.basename(sys.argv[0])])
129
130
131
132
133