1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
from wxPython.wx import *
|
1999-10-06 02:22:25 -04:00
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
import ColorPanel
|
2000-07-15 15:51:35 -04:00
|
|
|
import GridSimple
|
1999-10-06 02:22:25 -04:00
|
|
|
import wxListCtrl
|
|
|
|
import wxScrolledWindow
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2001-10-20 23:44:47 -04:00
|
|
|
import sys
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2000-01-31 16:07:04 -05:00
|
|
|
class TestNB(wxNotebook):
|
|
|
|
def __init__(self, parent, id, log):
|
|
|
|
wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
|
|
|
|
self.log = log
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
|
|
|
|
win = self.makeColorPanel(wxBLUE)
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "Blue")
|
2002-08-13 20:29:13 -04:00
|
|
|
st = wxStaticText(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.",
|
2000-01-31 16:07:04 -05:00
|
|
|
wxPoint(10, 10))
|
|
|
|
st.SetForegroundColour(wxWHITE)
|
|
|
|
st.SetBackgroundColour(wxBLUE)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxRED)
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "Red")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2000-01-31 16:07:04 -05:00
|
|
|
win = wxScrolledWindow.MyCanvas(self)
|
|
|
|
self.AddPage(win, 'ScrolledWindow')
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxGREEN)
|
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
|
|
|
|
2000-01-31 16:07:04 -05:00
|
|
|
win = wxListCtrl.TestListCtrlPanel(self, log)
|
|
|
|
self.AddPage(win, 'List')
|
1999-10-06 02:22:25 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxCYAN)
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "Cyan")
|
1999-10-06 02:22:25 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxWHITE)
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "White")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxBLACK)
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "Black")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "MIDNIGHT BLUE")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-08-13 20:29:13 -04:00
|
|
|
win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
|
2000-01-31 16:07:04 -05:00
|
|
|
self.AddPage(win, "INDIAN RED")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2000-01-31 16:07:04 -05:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
|
2002-04-29 14:55:23 -04:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
2002-08-13 20:29:13 -04: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 16:07:04 -05:00
|
|
|
def OnPageChanged(self, event):
|
2002-04-29 14:55:23 -04:00
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
|
|
|
self.log.write('OnPageChanged, old:%d, new:%d\n' % (old, new))
|
|
|
|
event.Skip()
|
|
|
|
|
|
|
|
def OnPageChanging(self, event):
|
|
|
|
old = event.GetOldSelection()
|
|
|
|
new = event.GetSelection()
|
|
|
|
self.log.write('OnPageChanging, old:%d, new:%d\n' % (old, new))
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
This class represents a notebook control, which manages multiple windows with associated tabs.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
"""
|
2001-10-20 23:44:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app = wxPySimpleApp()
|
|
|
|
frame = wxFrame(None, -1, "Test Notebook", size=(600, 400))
|
|
|
|
win = TestNB(frame, -1, sys.stdout)
|
|
|
|
frame.Show(true)
|
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
|