2003-10-01 19:28:31 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
2003-10-01 19:28:31 -04:00
|
|
|
|
2003-12-11 14:55:48 -05:00
|
|
|
import ColorPanel
|
2004-01-12 22:17:17 -05:00
|
|
|
import images
|
2003-12-11 14:55:48 -05:00
|
|
|
|
2003-11-21 02:36:53 -05:00
|
|
|
colourList = [ "Aquamarine", "Black", "Blue", "Blue Violet", "Brown", "Cadet Blue",
|
|
|
|
"Coral", "Cornflower Blue", "Cyan", "Dark Grey", "Dark Green",
|
2005-05-24 16:55:42 -04:00
|
|
|
"Dark Olive Green",
|
2003-11-21 02:36:53 -05:00
|
|
|
]
|
2003-10-01 19:28:31 -04:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestLB(wx.Listbook):
|
2003-10-01 19:28:31 -04:00
|
|
|
def __init__(self, parent, id, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Listbook.__init__(self, parent, id, style=
|
|
|
|
wx.LB_DEFAULT
|
2003-10-01 19:28:31 -04:00
|
|
|
#wxLB_TOP
|
|
|
|
#wxLB_BOTTOM
|
|
|
|
#wxLB_LEFT
|
|
|
|
#wxLB_RIGHT
|
|
|
|
)
|
|
|
|
self.log = log
|
|
|
|
|
2005-05-24 16:55:42 -04:00
|
|
|
# make an image list using the LBXX images
|
2003-12-11 14:55:48 -05:00
|
|
|
il = wx.ImageList(32, 32)
|
2005-05-24 16:55:42 -04:00
|
|
|
for x in range(12):
|
|
|
|
f = getattr(images, 'getLB%02dBitmap' % (x+1))
|
2003-11-21 02:36:53 -05:00
|
|
|
bmp = f()
|
|
|
|
il.Add(bmp)
|
2003-10-01 19:28:31 -04:00
|
|
|
self.AssignImageList(il)
|
2003-11-21 02:36:53 -05:00
|
|
|
|
|
|
|
# Now make a bunch of panels for the list book
|
|
|
|
first = True
|
|
|
|
imID = 0
|
|
|
|
for colour in colourList:
|
|
|
|
win = self.makeColorPanel(colour)
|
|
|
|
self.AddPage(win, colour, imageId=imID)
|
|
|
|
imID += 1
|
|
|
|
if imID == il.GetImageCount(): imID = 0
|
|
|
|
if first:
|
2003-12-11 14:55:48 -05:00
|
|
|
st = wx.StaticText(win.win, -1,
|
2003-11-21 02:36:53 -05:00
|
|
|
"You can put nearly any type of window here,\n"
|
|
|
|
"and the list can be on any side of the Listbook",
|
2003-12-11 14:55:48 -05:00
|
|
|
wx.Point(10, 10))
|
2003-11-21 02:36:53 -05:00
|
|
|
first = False
|
2003-10-01 19:28:31 -04:00
|
|
|
|
2004-01-22 18:56:00 -05:00
|
|
|
self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged)
|
|
|
|
self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging)
|
2003-10-01 19:28:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
def makeColorPanel(self, color):
|
2003-12-08 20:23:28 -05:00
|
|
|
p = wx.Panel(self, -1)
|
2003-10-01 19:28:31 -04:00
|
|
|
win = ColorPanel.ColoredPanel(p, color)
|
|
|
|
p.win = win
|
|
|
|
def OnCPSize(evt, win=win):
|
|
|
|
win.SetSize(evt.GetSize())
|
2003-12-08 20:23:28 -05:00
|
|
|
p.Bind(wx.EVT_SIZE, OnCPSize)
|
2003-10-01 19:28:31 -04:00
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
|
|
def OnPageChanged(self, event):
|
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
|
|
|
sel = self.GetSelection()
|
|
|
|
self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
|
|
|
event.Skip()
|
|
|
|
|
|
|
|
def OnPageChanging(self, event):
|
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
|
|
|
sel = self.GetSelection()
|
|
|
|
self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
|
|
|
event.Skip()
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
testWin = TestLB(nb, -1, log)
|
|
|
|
return testWin
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
<html><body>
|
2004-01-12 22:17:17 -05:00
|
|
|
<h2>wx.Listbook</h2>
|
2003-10-01 19:28:31 -04:00
|
|
|
<p>
|
|
|
|
This class is a control similar to a notebook control, but with a
|
2004-01-12 22:17:17 -05:00
|
|
|
wx.ListCtrl instead of a set of tabs.
|
2003-10-01 19:28:31 -04:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2003-10-01 19:28:31 -04:00
|
|
|
|
|
|
|
|
2004-01-22 18:56:00 -05:00
|
|
|
|