Phoenix Logo

phoenix_title wx.Treebook

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.

events Events Emitted by this Class

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.

class_hierarchy Class Hierarchy

Inheritance diagram for class Treebook:


method_summary Methods Summary

__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.

property_summary Properties Summary

Selection See GetSelection

api Class API



class 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.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=BK_DEFAULT, name=””)

Creates an empty wx.Treebook.

Parameters:
  • 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.

Parameters:
  • page (wx.Window) –
  • text (string) –
  • bSelect (bool) –
  • imageId (int) –
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:
  • page (wx.Window) –
  • text (string) –
  • bSelect (bool) –
  • imageId (int) –
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:
  • pageId (int) –
  • expand (bool) –
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:
  • pagePos (int) –
  • page (wx.Window) –
  • text (string) –
  • bSelect (bool) –
  • imageId (int) –
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:
  • pagePos (int) –
  • page (wx.Window) –
  • text (string) –
  • bSelect (bool) –
  • imageId (int) –
Return type:

bool



IsNodeExpanded(self, pageId)

Returns True if the page represented by pageId is expanded.

Parameters:pageId (int) –
Return type:bool

Properties



Selection

See GetSelection