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