]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxNotebook.py
2 from wxPython
. wx
import *
7 import wxScrolledWindow
11 #----------------------------------------------------------------------------
13 class TestNB ( wxNotebook
):
14 def __init__ ( self
, parent
, id , log
):
15 wxNotebook
.__ init
__ ( self
, parent
, id , style
= wxNB_BOTTOM
)
19 win
= self
. makeColorPanel ( wxBLUE
)
20 self
. AddPage ( win
, "Blue" )
21 st
= wxStaticText ( win
. win
, - 1 ,
22 "You can put nearly any type of window here, \n "
23 "and if the platform supports it then the \n "
24 "tabs can be on any side of the notebook." ,
26 st
. SetForegroundColour ( wxWHITE
)
27 st
. SetBackgroundColour ( wxBLUE
)
29 win
= self
. makeColorPanel ( wxRED
)
30 self
. AddPage ( win
, "Red" )
32 win
= wxScrolledWindow
. MyCanvas ( self
)
33 self
. AddPage ( win
, 'ScrolledWindow' )
35 win
= self
. makeColorPanel ( wxGREEN
)
36 self
. AddPage ( win
, "Green" )
38 win
= GridSimple
. SimpleGrid ( self
, log
)
39 self
. AddPage ( win
, "Grid" )
41 win
= wxListCtrl
. TestListCtrlPanel ( self
, log
)
42 self
. AddPage ( win
, 'List' )
44 win
= self
. makeColorPanel ( wxCYAN
)
45 self
. AddPage ( win
, "Cyan" )
47 win
= self
. makeColorPanel ( wxWHITE
)
48 self
. AddPage ( win
, "White" )
50 win
= self
. makeColorPanel ( wxBLACK
)
51 self
. AddPage ( win
, "Black" )
53 win
= self
. makeColorPanel ( wxNamedColour ( 'MIDNIGHT BLUE' ))
54 self
. AddPage ( win
, "MIDNIGHT BLUE" )
56 win
= self
. makeColorPanel ( wxNamedColour ( 'INDIAN RED' ))
57 self
. AddPage ( win
, "INDIAN RED" )
59 EVT_NOTEBOOK_PAGE_CHANGED ( self
, self
. GetId (), self
. OnPageChanged
)
60 EVT_NOTEBOOK_PAGE_CHANGING ( self
, self
. GetId (), self
. OnPageChanging
)
63 def makeColorPanel ( self
, color
):
65 win
= ColorPanel
. ColoredPanel ( p
, color
)
67 def OnCPSize ( evt
, win
= win
):
68 win
. SetSize ( evt
. GetSize ())
73 def OnPageChanged ( self
, event
):
74 old
= event
. GetOldSelection ()
75 new
= event
. GetSelection ()
76 self
. log
. write ( 'OnPageChanged, old: %d , new: %d \n ' % ( old
, new
))
79 def OnPageChanging ( self
, event
):
80 old
= event
. GetOldSelection ()
81 new
= event
. GetSelection ()
82 self
. log
. write ( 'OnPageChanging, old: %d , new: %d \n ' % ( old
, new
))
86 #----------------------------------------------------------------------------
88 def runTest ( frame
, nb
, log
):
89 testWin
= TestNB ( nb
, - 1 , log
)
92 #----------------------------------------------------------------------------
106 This class represents a notebook control, which manages multiple windows with associated tabs.
108 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.
113 if __name__
== "__main__" :
114 app
= wxPySimpleApp ()
115 frame
= wxFrame ( None , - 1 , "Test Notebook" , size
=( 600 , 400 ))
116 win
= TestNB ( frame
, - 1 , sys
. stdout
)