1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import sys
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import ColorPanel
|
|
|
|
import GridSimple
|
2004-01-03 01:14:17 +00:00
|
|
|
import ListCtrl
|
|
|
|
import ScrolledWindow
|
2003-12-09 01:23:28 +00:00
|
|
|
import images
|
2001-10-21 03:44:47 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestNB(wx.Notebook):
|
2000-01-31 21:07:04 +00:00
|
|
|
def __init__(self, parent, id, log):
|
2006-02-01 23:46:43 +00:00
|
|
|
wx.Notebook.__init__(self, parent, id, size=(21,21), style=
|
|
|
|
wx.BK_DEFAULT
|
|
|
|
#wx.BK_TOP
|
|
|
|
#wx.BK_BOTTOM
|
|
|
|
#wx.BK_LEFT
|
|
|
|
#wx.BK_RIGHT
|
|
|
|
# | wx.NB_MULTILINE
|
2004-08-10 01:21:16 +00:00
|
|
|
)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.log = log
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
win = self.makeColorPanel(wx.BLUE)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Blue")
|
2003-12-09 01:23:28 +00:00
|
|
|
st = wx.StaticText(win.win, -1,
|
2000-01-31 21:07:04 +00:00
|
|
|
"You can put nearly any type of window here,\n"
|
2002-08-13 23:59:08 +00:00
|
|
|
"and if the platform supports it then the\n"
|
|
|
|
"tabs can be on any side of the notebook.",
|
2003-12-09 01:23:28 +00:00
|
|
|
(10, 10))
|
|
|
|
|
|
|
|
st.SetForegroundColour(wx.WHITE)
|
|
|
|
st.SetBackgroundColour(wx.BLUE)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
# Show how to put an image on one of the notebook tabs,
|
|
|
|
# first make the image list:
|
2003-12-09 01:23:28 +00:00
|
|
|
il = wx.ImageList(16, 16)
|
2003-03-25 06:35:27 +00:00
|
|
|
idx1 = il.Add(images.getSmilesBitmap())
|
|
|
|
self.AssignImageList(il)
|
|
|
|
|
|
|
|
# now put an image on the first tab we just created:
|
|
|
|
self.SetPageImage(0, idx1)
|
|
|
|
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
win = self.makeColorPanel(wx.RED)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Red")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2004-01-03 01:14:17 +00:00
|
|
|
win = ScrolledWindow.MyCanvas(self)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, 'ScrolledWindow')
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
win = self.makeColorPanel(wx.GREEN)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Green")
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
win = GridSimple.SimpleGrid(self, log)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Grid")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2004-01-03 01:14:17 +00:00
|
|
|
win = ListCtrl.TestListCtrlPanel(self, log)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, 'List')
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
win = self.makeColorPanel(wx.CYAN)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Cyan")
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2006-02-02 01:47:16 +00:00
|
|
|
win = self.makeColorPanel(wx.NamedColour('Midnight Blue'))
|
|
|
|
self.AddPage(win, "Midnight Blue")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2006-02-02 01:47:16 +00:00
|
|
|
win = self.makeColorPanel(wx.NamedColour('Indian Red'))
|
|
|
|
self.AddPage(win, "Indian Red")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
|
|
|
|
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
def makeColorPanel(self, color):
|
2003-12-09 01:23:28 +00:00
|
|
|
p = wx.Panel(self, -1)
|
2002-08-14 00:29:13 +00:00
|
|
|
win = ColorPanel.ColoredPanel(p, color)
|
|
|
|
p.win = win
|
|
|
|
def OnCPSize(evt, win=win):
|
2006-02-02 01:47:16 +00:00
|
|
|
win.SetPosition((0,0))
|
2002-08-14 00:29:13 +00:00
|
|
|
win.SetSize(evt.GetSize())
|
2003-12-09 01:23:28 +00:00
|
|
|
p.Bind(wx.EVT_SIZE, OnCPSize)
|
|
|
|
return p
|
2002-08-14 00:29:13 +00:00
|
|
|
|
2006-02-02 01:47:16 +00:00
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
def OnPageChanged(self, event):
|
2002-04-29 18:55:23 +00:00
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
2003-07-02 23:13:10 +00:00
|
|
|
sel = self.GetSelection()
|
|
|
|
self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
2002-04-29 18:55:23 +00:00
|
|
|
event.Skip()
|
|
|
|
|
|
|
|
def OnPageChanging(self, event):
|
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
2003-07-02 23:13:10 +00:00
|
|
|
sel = self.GetSelection()
|
|
|
|
self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
|
2000-01-31 21:07:04 +00:00
|
|
|
event.Skip()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
#----------------------------------------------------------------------------
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
def runTest(frame, nb, log):
|
|
|
|
testWin = TestNB(nb, -1, log)
|
|
|
|
return testWin
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
overview = """\
|
|
|
|
<html><body>
|
2004-01-13 03:17:17 +00:00
|
|
|
<h2>wx.Notebook</h2>
|
2003-03-25 06:35:27 +00:00
|
|
|
<p>
|
|
|
|
This class represents a notebook control, which manages multiple
|
|
|
|
windows with associated tabs.
|
|
|
|
<p>
|
2004-01-13 03:17:17 +00:00
|
|
|
To use the class, create a wx.Notebook object and call AddPage or
|
2003-03-25 06:35:27 +00:00
|
|
|
InsertPage, passing a window to be used as the page. Do not explicitly
|
2004-01-13 03:17:17 +00:00
|
|
|
delete the window for a page that is currently managed by wx.Notebook.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
"""
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-21 03:44:47 +00:00
|
|
|
|