This class is an extension of the wx.Notebook class that allows a tree structured set of pages to be shown in a control.
A classic example is a netscape preferences dialog that shows a tree of preference sections on the left and select section page on the right.
To use the class simply create it and populate with pages using InsertPage
, InsertSubPage
, AddPage
, AddSubPage
.
If your tree is no more than 1 level in depth then you could simply use AddPage
and AddSubPage
to sequentially populate your tree by adding at every step a page or a subpage to the end of the tree.
^^
Handlers bound for the following event types will receive a wx.BookCtrlEvent parameter.
EVT_TREEBOOK_PAGE_CHANGED: The page selection was changed. Processes a wxEVT_TREEBOOK_PAGE_CHANGED
event.
EVT_TREEBOOK_PAGE_CHANGING: The page selection is about to be changed. Processes a wxEVT_TREEBOOK_PAGE_CHANGING
event. This event can be vetoed
.
EVT_TREEBOOK_NODE_COLLAPSED: The page node is going to be collapsed. Processes a wxEVT_TREEBOOK_NODE_COLLAPSED
event.
EVT_TREEBOOK_NODE_EXPANDED: The page node is going to be expanded. Processes a wxEVT_TREEBOOK_NODE_EXPANDED
event. ^^
See also
wx.BookCtrl
, wx.BookCtrlEvent, wx.Notebook, wx.TreeCtrl, wx.ImageList, BookCtrl Overview, Notebook Sample
Default constructor. |
|
Adds a new page. |
|
Adds a new child-page to the last top-level page. |
|
Shortcut for |
|
Creates a treebook control. |
|
Deletes the page at the specified position and all its children. |
|
Expands (collapses) the pageId node. |
|
Returns the parent page of the given one or |
|
Returns the currently selected page, or |
|
Returns the tree control used for selecting pages. |
|
Inserts a new page just before the page indicated by pagePos. |
|
Inserts a sub page under the specified page. |
|
Returns |
See |
|
See |
wx.
Treebook
(BookCtrlBase)¶Possible constructors:
Treebook()
Treebook(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
style=BK_DEFAULT, name="")
This class is an extension of the Notebook class that allows a tree structured set of pages to be shown in a control.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=BK_DEFAULT, name=””)
Creates an empty wx.Treebook.
parent (wx.Window) – The parent window. Must be not None
.
id (wx.WindowID) – The window identifier.
pos (wx.Point) – The window position.
size (wx.Size) – The window size.
style (long) – The window style. See wx.Notebook.
name (string) – The name of the control (used only under Motif).
AddPage
(self, page, text, bSelect=False, imageId=NOT_FOUND)¶Adds a new page.
The page is placed at the topmost level after all other pages. None
could be specified for page to create an empty page.
page (wx.Window) –
text (string) –
bSelect (bool) –
imageId (int) –
bool
AddSubPage
(self, page, text, bSelect=False, imageId=NOT_FOUND)¶Adds a new child-page to the last top-level page.
None
could be specified for page to create an empty page.
page (wx.Window) –
text (string) –
bSelect (bool) –
imageId (int) –
bool
CollapseNode
(self, pageId)¶Shortcut for ExpandNode
( pageId, False
).
pageId (int) –
bool
Create
(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=BK_DEFAULT, name="")¶Creates a treebook control.
See Treebook.__init__
for the description of the parameters.
DeletePage
(self, pagePos)¶Deletes the page at the specified position and all its children.
Could trigger page selection change in a case when selected page is removed. In that case its parent is selected (or the next page if no parent).
pagePos (int) –
bool
ExpandNode
(self, pageId, expand=True)¶Expands (collapses) the pageId node.
Returns the previous state. May generate page changing events (if selected page is under the collapsed branch, then its parent is autoselected).
pageId (int) –
expand (bool) –
bool
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetPageParent
(self, page)¶Returns the parent page of the given one or NOT_FOUND
if this is a top-level page.
page (int) –
int
GetSelection
(self)¶Returns the currently selected page, or NOT_FOUND
if none was selected.
int
Note
This method may return either the previously or newly selected page when called from the EVT_TREEBOOK_PAGE_CHANGED() handler depending on the platform and so wx.BookCtrlEvent.GetSelection
should be used instead in this case.
GetTreeCtrl
(self)¶Returns the tree control used for selecting pages.
InsertPage
(self, pagePos, page, text, bSelect=False, imageId=NOT_FOUND)¶Inserts a new page just before the page indicated by pagePos.
The new page is placed before pagePos page and on the same level. None
could be specified for page to create an empty page.
pagePos (int) –
page (wx.Window) –
text (string) –
bSelect (bool) –
imageId (int) –
bool
InsertSubPage
(self, pagePos, page, text, bSelect=False, imageId=NOT_FOUND)¶Inserts a sub page under the specified page.
None
could be specified for page to create an empty page.
pagePos (int) –
page (wx.Window) –
text (string) –
bSelect (bool) –
imageId (int) –
bool
IsNodeExpanded
(self, pageId)¶Returns True
if the page represented by pageId is expanded.
pageId (int) –
bool
Selection
¶See GetSelection
TreeCtrl
¶See GetTreeCtrl