]>
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
)
18 win
= ColorPanel
. ColoredPanel ( self
, wxBLUE
)
19 self
. AddPage ( win
, "Blue" )
20 st
= wxStaticText ( win
, - 1 ,
21 "You can put nearly any type of window here, \n "
22 "and the tabs can be on any side... (look below.)" ,
24 st
. SetForegroundColour ( wxWHITE
)
25 st
. SetBackgroundColour ( wxBLUE
)
27 win
= ColorPanel
. ColoredPanel ( self
, wxRED
)
28 self
. AddPage ( win
, "Red" )
30 win
= wxScrolledWindow
. MyCanvas ( self
)
31 self
. AddPage ( win
, 'ScrolledWindow' )
33 win
= ColorPanel
. ColoredPanel ( self
, wxGREEN
)
34 self
. AddPage ( win
, "Green" )
36 win
= GridSimple
. SimpleGrid ( self
, log
)
37 self
. AddPage ( win
, "Grid" )
39 win
= wxListCtrl
. TestListCtrlPanel ( self
, log
)
40 self
. AddPage ( win
, 'List' )
42 win
= ColorPanel
. ColoredPanel ( self
, wxCYAN
)
43 self
. AddPage ( win
, "Cyan" )
45 win
= ColorPanel
. ColoredPanel ( self
, wxWHITE
)
46 self
. AddPage ( win
, "White" )
48 win
= ColorPanel
. ColoredPanel ( self
, wxBLACK
)
49 self
. AddPage ( win
, "Black" )
51 win
= ColorPanel
. ColoredPanel ( self
, wxNamedColour ( 'MIDNIGHT BLUE' ))
52 self
. AddPage ( win
, "MIDNIGHT BLUE" )
54 win
= ColorPanel
. ColoredPanel ( self
, wxNamedColour ( 'INDIAN RED' ))
55 self
. AddPage ( win
, "INDIAN RED" )
57 EVT_NOTEBOOK_PAGE_CHANGED ( self
, self
. GetId (), self
. OnPageChanged
)
58 EVT_NOTEBOOK_PAGE_CHANGING ( self
, self
. GetId (), self
. OnPageChanging
)
61 def OnPageChanged ( self
, event
):
62 old
= event
. GetOldSelection ()
63 new
= event
. GetSelection ()
64 self
. log
. write ( 'OnPageChanged, old: %d , new: %d \n ' % ( old
, new
))
67 def OnPageChanging ( self
, event
):
68 old
= event
. GetOldSelection ()
69 new
= event
. GetSelection ()
70 self
. log
. write ( 'OnPageChanging, old: %d , new: %d \n ' % ( old
, new
))
74 #----------------------------------------------------------------------------
76 def runTest ( frame
, nb
, log
):
77 testWin
= TestNB ( nb
, - 1 , log
)
80 #----------------------------------------------------------------------------
94 This class represents a notebook control, which manages multiple windows with associated tabs.
96 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.
101 if __name__
== "__main__" :
102 app
= wxPySimpleApp ()
103 frame
= wxFrame ( None , - 1 , "Test Notebook" , size
=( 600 , 400 ))
104 win
= TestNB ( frame
, - 1 , sys
. stdout
)