| 1 | |
| 2 | import wx |
| 3 | |
| 4 | import ColorPanel |
| 5 | import images |
| 6 | |
| 7 | colourList = [ "Aquamarine", "Black", "Blue", "Blue Violet", "Brown", "Cadet Blue", |
| 8 | "Coral", "Cornflower Blue", "Cyan", "Dark Grey", "Dark Green", |
| 9 | "Dark Olive Green", "Dark Orchid", "Dark Slate Blue", |
| 10 | "Dark Slate Grey", "Dark Turquoise", "Dim Grey", "Firebrick", |
| 11 | "Forest Green", "Gold", "Goldenrod", "Grey", "Green", "Green Yellow", |
| 12 | "Indian Red", "Khaki", "Light Blue", "Light Grey", "Light Steel Blue", |
| 13 | "Lime Green", "Magenta", "Maroon", "Medium Aquamarine", "Medium Blue", |
| 14 | "Medium Forest Green", "Medium Goldenrod", "Medium Orchid", |
| 15 | "Medium Sea Green", "Medium Slate Blue", "Medium Spring Green", |
| 16 | "Medium Turquoise", "Medium Violet Red", "Midnight Blue", "Navy", |
| 17 | "Orange", "Orange Red", "Orchid", "Pale Green", "Pink", "Plum", |
| 18 | "Purple", "Red", "Salmon", "Sea Green", "Sienna", "Sky Blue", |
| 19 | "Slate Blue", "Spring Green", "Steel Blue", "Tan", "Thistle", |
| 20 | "Turquoise", "Violet", "Violet Red", "Wheat", "White", "Yellow", |
| 21 | "Yellow Green" |
| 22 | ] |
| 23 | |
| 24 | #---------------------------------------------------------------------------- |
| 25 | |
| 26 | class TestLB(wx.Listbook): |
| 27 | def __init__(self, parent, id, log): |
| 28 | wx.Listbook.__init__(self, parent, id, style= |
| 29 | wx.LB_DEFAULT |
| 30 | #wxLB_TOP |
| 31 | #wxLB_BOTTOM |
| 32 | #wxLB_LEFT |
| 33 | #wxLB_RIGHT |
| 34 | ) |
| 35 | self.log = log |
| 36 | |
| 37 | # make an image list using the BlomXX images |
| 38 | il = wx.ImageList(32, 32) |
| 39 | for x in range(1, 16): |
| 40 | f = getattr(images, 'getBlom%02dBitmap' % x) |
| 41 | bmp = f() |
| 42 | il.Add(bmp) |
| 43 | self.AssignImageList(il) |
| 44 | |
| 45 | # Now make a bunch of panels for the list book |
| 46 | first = True |
| 47 | imID = 0 |
| 48 | for colour in colourList: |
| 49 | win = self.makeColorPanel(colour) |
| 50 | self.AddPage(win, colour, imageId=imID) |
| 51 | imID += 1 |
| 52 | if imID == il.GetImageCount(): imID = 0 |
| 53 | if first: |
| 54 | st = wx.StaticText(win.win, -1, |
| 55 | "You can put nearly any type of window here,\n" |
| 56 | "and the list can be on any side of the Listbook", |
| 57 | wx.Point(10, 10)) |
| 58 | #st.SetForegroundColour(wxWHITE) |
| 59 | #st.SetBackgroundColour(wxBLUE) |
| 60 | first = False |
| 61 | |
| 62 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged) |
| 63 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging) |
| 64 | |
| 65 | |
| 66 | def makeColorPanel(self, color): |
| 67 | p = wx.Panel(self, -1) |
| 68 | win = ColorPanel.ColoredPanel(p, color) |
| 69 | p.win = win |
| 70 | def OnCPSize(evt, win=win): |
| 71 | win.SetSize(evt.GetSize()) |
| 72 | p.Bind(wx.EVT_SIZE, OnCPSize) |
| 73 | return p |
| 74 | |
| 75 | |
| 76 | def OnPageChanged(self, event): |
| 77 | old = event.GetOldSelection() |
| 78 | new = event.GetSelection() |
| 79 | sel = self.GetSelection() |
| 80 | self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) |
| 81 | event.Skip() |
| 82 | |
| 83 | def OnPageChanging(self, event): |
| 84 | old = event.GetOldSelection() |
| 85 | new = event.GetSelection() |
| 86 | sel = self.GetSelection() |
| 87 | self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) |
| 88 | event.Skip() |
| 89 | |
| 90 | #---------------------------------------------------------------------------- |
| 91 | |
| 92 | def runTest(frame, nb, log): |
| 93 | testWin = TestLB(nb, -1, log) |
| 94 | return testWin |
| 95 | |
| 96 | #---------------------------------------------------------------------------- |
| 97 | |
| 98 | |
| 99 | overview = """\ |
| 100 | <html><body> |
| 101 | <h2>wx.Listbook</h2> |
| 102 | <p> |
| 103 | This class is a control similar to a notebook control, but with a |
| 104 | wx.ListCtrl instead of a set of tabs. |
| 105 | |
| 106 | """ |
| 107 | |
| 108 | |
| 109 | |
| 110 | if __name__ == '__main__': |
| 111 | import sys,os |
| 112 | import run |
| 113 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
| 114 | |
| 115 | |
| 116 | |