1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
from wxPython.wx import *
|
1999-10-06 06:22:25 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
import ColorPanel
|
2000-07-15 19:51:35 +00:00
|
|
|
import GridSimple
|
1999-10-06 06:22:25 +00:00
|
|
|
import wxListCtrl
|
|
|
|
import wxScrolledWindow
|
2003-03-25 06:35:27 +00:00
|
|
|
import images
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2001-10-21 03:44:47 +00:00
|
|
|
import sys
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
class TestNB(wxNotebook):
|
|
|
|
def __init__(self, parent, id, log):
|
2003-03-25 06:35:27 +00:00
|
|
|
wxNotebook.__init__(self, parent, id, style=
|
2003-07-02 23:13:10 +00:00
|
|
|
#wxNB_TOP
|
2003-03-25 06:35:27 +00:00
|
|
|
wxNB_BOTTOM
|
|
|
|
#wxNB_LEFT
|
|
|
|
#wxNB_RIGHT
|
|
|
|
)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.log = log
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxBLUE)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Blue")
|
2002-08-14 00:29:13 +00:00
|
|
|
st = wxStaticText(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.",
|
2000-01-31 21:07:04 +00:00
|
|
|
wxPoint(10, 10))
|
|
|
|
st.SetForegroundColour(wxWHITE)
|
|
|
|
st.SetBackgroundColour(wxBLUE)
|
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:
|
|
|
|
il = wxImageList(16, 16)
|
|
|
|
idx1 = il.Add(images.getSmilesBitmap())
|
|
|
|
self.AssignImageList(il)
|
|
|
|
|
|
|
|
# now put an image on the first tab we just created:
|
|
|
|
self.SetPageImage(0, idx1)
|
|
|
|
|
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxRED)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Red")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
win = wxScrolledWindow.MyCanvas(self)
|
|
|
|
self.AddPage(win, 'ScrolledWindow')
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxGREEN)
|
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
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
win = wxListCtrl.TestListCtrlPanel(self, log)
|
|
|
|
self.AddPage(win, 'List')
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxCYAN)
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "Cyan")
|
1999-10-06 06:22:25 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
## win = self.makeColorPanel(wxWHITE)
|
|
|
|
## self.AddPage(win, "White")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
## win = self.makeColorPanel(wxBLACK)
|
|
|
|
## self.AddPage(win, "Black")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "MIDNIGHT BLUE")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
|
2000-01-31 21:07:04 +00:00
|
|
|
self.AddPage(win, "INDIAN RED")
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2000-01-31 21:07:04 +00:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
|
2002-04-29 18:55:23 +00:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2002-08-14 00:29:13 +00:00
|
|
|
def makeColorPanel(self, color):
|
|
|
|
p = wxPanel(self, -1)
|
|
|
|
win = ColorPanel.ColoredPanel(p, color)
|
|
|
|
p.win = win
|
|
|
|
def OnCPSize(evt, win=win):
|
|
|
|
win.SetSize(evt.GetSize())
|
|
|
|
EVT_SIZE(p, OnCPSize)
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
<h2>wxNotebook</h2>
|
|
|
|
<p>
|
|
|
|
This class represents a notebook control, which manages multiple
|
|
|
|
windows with associated tabs.
|
|
|
|
<p>
|
|
|
|
To use the class, create a wxNotebook object and call AddPage or
|
|
|
|
InsertPage, passing a window to be used as the page. Do not explicitly
|
|
|
|
delete the window for a page that is currently managed by wxNotebook.
|
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
|
|
|
|
run.main(['', os.path.basename(sys.argv[0])])
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-21 03:44:47 +00:00
|
|
|
|