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
wx.aui.AuiNotebook, wx.Choicebook, wx.Listbook, wx.Notebook, wx.Simplebook, wx.Toolbook, wx.Treebook
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. |
See |
|
See |
|
See |
|
See |
wx.
BookCtrlBase
(Control, WithImages)¶Possible constructors:
BookCtrlBase()
BookCtrlBase(parent, winid, pos=DefaultPosition, size=DefaultSize,
style=0, name="")
A book control is a convenient way of displaying multiple pages of information, displayed one page at a time.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__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.
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
is True
, 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).
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.
bool
True
if successful, False
otherwise.
AdvanceSelection
(self, forward=True)¶Cycles through the tabs.
The call to this function generates the page changing events.
forward (bool) –
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.
page (int) –
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.
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.
page (int) –
bool
FindPage
(self, page)¶Returns the index of the specified tab window or NOT_FOUND
if not found.
page (wx.Window) – One of the control pages.
int
The zero-based tab index or NOT_FOUND
if not found.
New 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.
Non-owning pointer to the sizer or None
.
GetPage
(self, page)¶Returns the window at the given page position.
page (int) –
GetPageCount
(self)¶Returns the number of pages in the control.
int
GetPageImage
(self, nPage)¶Returns the image index for the given page.
nPage (int) –
int
GetPageText
(self, nPage)¶Returns the string for the given page.
nPage (int) –
string
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 so wx.BookCtrlEvent.GetSelection
should be used instead in this case.
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.
pt (wx.Point) – Specifies the point for the hit test.
tuple
( int, flags )
InsertPage
(self, index, page, text, select=False, imageId=NO_IMAGE)¶Inserts a new page at the specified position.
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.
bool
True
if successful, False
otherwise.
RemovePage
(self, page)¶Deletes the specified page, without deleting the associated window.
See DeletePage
for a note about the events generated by this function.
page (int) –
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
.
page (int) –
image (int) –
bool
SetPageSize
(self, size)¶Sets the width and height of the pages.
size (wx.Size) –
Note
This method is currently not implemented for wxGTK.
SetPageText
(self, page, text)¶Sets the text for the given page.
page (int) –
text (string) –
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.
page (int) –
int
See also
ControlSizer
¶See GetControlSizer
CurrentPage
¶See GetCurrentPage
PageCount
¶See GetPageCount
Selection
¶See GetSelection
and SetSelection