wx.BookCtrlBase¶
A book control is a convenient way of displaying multiple pages of information, displayed one page at a time.
wxWidgets has five variants of this control:
wx.Choicebook: controlled by a wx.Choice
wx.Listbook: controlled by a wx.ListCtrl
wx.Notebook: uses a row of tabs
wx.Treebook: controlled by a wx.TreeCtrl
wx.Toolbook: controlled by a wx.ToolBar
This abstract class is the parent of all these book controls, and provides their basic interface. This is a pure virtual class so you cannot allocate it directly.
See also
Class Hierarchy¶
Known Subclasses¶
wx.aui.AuiNotebook, wx.Choicebook, wx.Listbook, wx.Notebook, wx.Simplebook, wx.Toolbook, wx.Treebook
Methods Summary¶
Default constructor. |
|
Adds a new page. |
|
Cycles through the tabs. |
|
Changes the selection to the given page, returning the previous selection. |
|
Constructs the book control with the given parameters. |
|
Deletes all pages. |
|
Deletes the specified page, and the associated window. |
|
Returns the index of the specified tab window or |
|
Returns the sizer containing the control for page selection, if any. |
|
Returns the currently selected page or |
|
Returns the window at the given page position. |
|
Returns the number of pages in the control. |
|
Returns the image index for the given page. |
|
Returns the string for the given page. |
|
Returns the currently selected page, or |
|
Returns the index of the tab at the specified position or |
|
Inserts a new page at the specified position. |
|
Deletes the specified page, without deleting the associated window. |
|
Sets the image index for the given page. |
|
Sets the width and height of the pages. |
|
Sets the text for the given page. |
|
Sets the selection to the given page, returning the previous selection. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.BookCtrlBase(Control, WithImages)¶
Possible constructors:
BookCtrlBase() -> None BookCtrlBase(parent, winid, pos=DefaultPosition, size=DefaultSize, style=0, name='') -> None
A book control is a convenient way of displaying multiple pages of information, displayed one page at a time.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
- Return type:
None
__init__ (self, parent, winid, pos=DefaultPosition, size=DefaultSize, style=0, name=’’)
Constructs the book control with the given parameters.
See
Create
for two-step construction.- Parameters:
- Return type:
None
- AddPage(self, page, text, select=False, imageId=NO_IMAGE)¶
Adds a new page.
The page must have the book control itself as the parent and must not have been added to this control previously.
The call to this function will generate the page changing and page changed events if
select
isTrue
, but not when inserting the very first page (as there is no previous page selection to switch from in this case and so it wouldn’t make sense to e.g. veto such event).- Parameters:
page (wx.Window) – Specifies the new page.
text (string) – Specifies the text for the new page.
select (bool) – Specifies whether the page should be selected.
imageId (int) – Specifies the optional image index for the new page.
- Return type:
bool
- Returns:
True
if successful,False
otherwise.
Note
Do not delete the page, it will be deleted by the book control.
See also
- AdvanceSelection(self, forward=True)¶
Cycles through the tabs.
The call to this function generates the page changing events.
- Parameters:
forward (bool)
- Return type:
None
- ChangeSelection(self, page)¶
Changes the selection to the given page, returning the previous selection.
This function behaves as
SetSelection
but does not generate the page changing events.See User Generated Events vs Programmatically Generated Events for more information.
- Parameters:
page (int)
- Return type:
int
- Create(self, parent, winid, pos=DefaultPosition, size=DefaultSize, style=0, name='')¶
Constructs the book control with the given parameters.
- DeleteAllPages(self)¶
Deletes all pages.
- Return type:
bool
- DeletePage(self, page)¶
Deletes the specified page, and the associated window.
The call to this function generates the page changing events when deleting the currently selected page or a page preceding it in the index order, but it does not send any events when deleting the last page: while in this case the selection also changes, it becomes invalid and for compatibility reasons the control never generates events with the invalid selection index.
- Parameters:
page (int)
- Return type:
bool
- FindPage(self, page)¶
Returns the index of the specified tab window or
NOT_FOUND
if not found.- Parameters:
page (wx.Window) – One of the control pages.
- Return type:
int
- Returns:
The zero-based tab index or
NOT_FOUND
if not found.
Added in version 2.9.5.
- GetControlSizer(self)¶
Returns the sizer containing the control for page selection, if any.
Some derived classes, e.g. wx.Choicebook, use a separate control for switching the currently selected page and this function returns the sizer used for positioning this control and the pages themselves inside the book control.
Note that many classes, notably wx.Notebook, do not use any such control, and this function simply returns
None
for them.- Return type:
- Returns:
Non-owning pointer to the sizer or
None
.
- GetPage(self, page)¶
Returns the window at the given page position.
- Parameters:
page (int)
- Return type:
- GetPageCount(self)¶
Returns the number of pages in the control.
- Return type:
int
- GetPageImage(self, nPage)¶
Returns the image index for the given page.
- Parameters:
nPage (int)
- Return type:
int
- GetPageText(self, nPage)¶
Returns the string for the given page.
- Parameters:
nPage (int)
- Return type:
str
- GetSelection(self)¶
Returns the currently selected page, or
NOT_FOUND
if none was selected.Note that this method may return either the previously or newly selected page when called from the
EVT_BOOKCTRL_PAGE_CHANGED
handler depending on the platform and sowx.BookCtrlEvent.GetSelection
should be used instead in this case.- Return type:
int
- HitTest(self, pt)¶
Returns the index of the tab at the specified position or
NOT_FOUND
if none.If flags parameter is not
None
, the position of the point inside the tab is returned as well.- Parameters:
pt (wx.Point) – Specifies the point for the hit test.
- Return type:
Tuple[int, int]
- Returns:
Returns the zero-based tab index or
NOT_FOUND
if there is no tab at the specified position.
- InsertPage(self, index, page, text, select=False, imageId=NO_IMAGE)¶
Inserts a new page at the specified position.
- Parameters:
index (int) – Specifies the position for the new page.
page (wx.Window) – Specifies the new page.
text (string) – Specifies the text for the new page.
select (bool) – Specifies whether the page should be selected.
imageId (int) – Specifies the optional image index for the new page.
- Return type:
bool
- Returns:
True
if successful,False
otherwise.
Note
Do not delete the page, it will be deleted by the book control.
See also
- RemovePage(self, page)¶
Deletes the specified page, without deleting the associated window.
See
DeletePage
for a note about the events generated by this function.- Parameters:
page (int)
- Return type:
bool
- SetPageImage(self, page, image)¶
Sets the image index for the given page.
image is an index into the image list which was set with
SetImageList
.- Parameters:
page (int)
image (int)
- Return type:
bool
- SetPageSize(self, size)¶
Sets the width and height of the pages.
- Parameters:
size (wx.Size)
- Return type:
None
Note
This method is currently not implemented for wxGTK.
- SetPageText(self, page, text)¶
Sets the text for the given page.
- Parameters:
page (int)
text (string)
- Return type:
bool
- SetSelection(self, page)¶
Sets the selection to the given page, returning the previous selection.
Notice that the call to this function generates the page changing events, use the
ChangeSelection
function if you don’t want these events to be generated.- Parameters:
page (int)
- Return type:
int
See also
Properties¶
- ControlSizer¶
See
GetControlSizer
- CurrentPage¶
See
GetCurrentPage
- PageCount¶
See
GetPageCount
- Selection¶
See
GetSelection
andSetSelection