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.
wxEVT_TREEBOOK_PAGE_CHANGED
event.wxEVT_TREEBOOK_PAGE_CHANGING
event. This event can be vetoed
.wxEVT_TREEBOOK_NODE_COLLAPSED
event.wxEVT_TREEBOOK_NODE_EXPANDED
event.See also
wx.BookCtrl
, wx.BookCtrlEvent, wx.Notebook, wx.TreeCtrl, wx.ImageList, BookCtrl Overview, Notebook Sample
__init__ |
Default constructor. |
AddPage |
Adds a new page. |
AddSubPage |
Adds a new child-page to the last top-level page. |
CollapseNode |
Shortcut for ExpandNode ( pageId, False ). |
Create |
Creates a treebook control. |
DeletePage |
Deletes the page at the specified position and all its children. |
ExpandNode |
Expands (collapses) the pageId node. |
GetPageParent |
Returns the parent page of the given one or NOT_FOUND if this is a top-level page. |
GetSelection |
Returns the currently selected page, or NOT_FOUND if none was selected. |
InsertPage |
Inserts a new page just before the page indicated by pagePos. |
InsertSubPage |
Inserts a sub page under the specified page. |
IsNodeExpanded |
Returns True if the page represented by pageId is expanded. |
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.
Parameters: |
|
---|
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.
Parameters: |
|
---|---|
Return type: | 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.
Parameters: |
|
---|---|
Return type: | bool |
CollapseNode
(self, pageId)¶Shortcut for ExpandNode
( pageId, False
).
Parameters: | pageId (int) – |
---|---|
Return type: | 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.
Parameters: | |
---|---|
Return type: | bool |
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).
Parameters: | pagePos (int) – |
---|---|
Return type: | 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).
Parameters: |
|
---|---|
Return type: | bool |
GetPageParent
(self, page)¶Returns the parent page of the given one or NOT_FOUND
if this is a top-level page.
Parameters: | page (int) – |
---|---|
Return type: | int |
GetSelection
(self)¶Returns the currently selected page, or NOT_FOUND
if none was selected.
Return type: | 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.
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.
Parameters: |
|
---|---|
Return type: | 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.
Parameters: |
|
---|---|
Return type: | bool |
IsNodeExpanded
(self, pageId)¶Returns True
if the page represented by pageId is expanded.
Parameters: | pageId (int) – |
---|---|
Return type: | bool |
Selection
¶See GetSelection