wx.BookCtrlBase

时间:2021-08-12 10:52:56

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:

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.

wx.BookCtrlBase Class Hierarchy

wx.BookCtrlBase Inheritance diagram for class BookCtrlBase:

wx.BookCtrlBase

wx.BookCtrlBase Known Subclasses

wx.aui.AuiNotebookwx.Choicebookwx.Listbookwx.NotebookSimplebook , wx.Toolbookwx.Treebook

wx.BookCtrlBase Methods Summary

__init__ Default constructor.
AddPage Adds a new page.
AdvanceSelection Cycles through the tabs.
ChangeSelection Changes the selection to the given page, returning the previous selection.
Create Constructs the book control with the given parameters.
DeleteAllPages Deletes all pages.
DeletePage Deletes the specified page, and the associated window.
FindPage Returns the index of the specified tab window or NOT_FOUND if not found.
GetCurrentPage Returns the currently selected page or None.
GetPage Returns the window at the given page position.
GetPageCount Returns the number of pages in the control.
GetPageImage Returns the image index for the given page.
GetPageText Returns the string for the given page.
GetSelection Returns the currently selected page, or NOT_FOUND if none was selected.
HitTest Returns the index of the tab at the specified position or NOT_FOUND if none.
InsertPage Inserts a new page at the specified position.
RemovePage Deletes the specified page, without deleting the associated window.
SetPageImage Sets the image index for the given page.
SetPageSize Sets the width and height of the pages.
SetPageText Sets the text for the given page.
SetSelection Sets the selection to the given page, returning the previous selection.

wx.BookCtrlBase Class API


class wx.BookCtrlBase(ControlWithImages)

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.

Methods


__init__(self*args**kw)

wx.BookCtrlBase Overloaded Implementations:


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

Parameters:
  • parent (wx.Window) –
  • winid (wx.WindowID) –
  • pos (wx.Point) –
  • size (wx.Size) –
  • style (long) –
  • name (string) –


AddPage(selfpagetextselect=FalseimageId=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 may generate the page changing events.

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

InsertPage


AdvanceSelection(selfforward=True)

Cycles through the tabs.

The call to this function generates the page changing events.

Parameters: forward (bool) –


ChangeSelection(selfpage)

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(selfparentwinidpos=DefaultPositionsize=DefaultSizestyle=0name="")

Constructs the book control with the given parameters.

Parameters:
  • parent (wx.Window) –
  • winid (wx.WindowID) –
  • pos (wx.Point) –
  • size (wx.Size) –
  • style (long) –
  • name (string) –
Return type:

bool


DeleteAllPages(self)

Deletes all pages.

Return type: bool


DeletePage(selfpage)

Deletes the specified page, and the associated window.

The call to this function generates the page changing events.

Parameters: page (int) –
Return type: bool


FindPage(selfpage)

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.

New in version 2.9.5.


GetCurrentPage(self)

Returns the currently selected page or None.

Return type: wx.Window


GetPage(selfpage)

Returns the window at the given page position.

Parameters: page (int) –
Return type: wx.Window


GetPageCount(self)

Returns the number of pages in the control.

Return type: int


GetPageImage(selfnPage)

Returns the image index for the given page.

Parameters: nPage (int) –
Return type: int


GetPageText(selfnPage)

Returns the string for the given page.

Parameters: nPage (int) –
Return type: 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.

Return type: int


HitTest(selfpt)

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
Returns: intflags )


InsertPage(selfindexpagetextselect=FalseimageId=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

AddPage


RemovePage(selfpage)

Deletes the specified page, without deleting the associated window.

Parameters: page (int) –
Return type: bool


SetPageImage(selfpageimage)

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(selfsize)

Sets the width and height of the pages.

Parameters: size (wx.Size) –

Note

This method is currently not implemented for wxGTK.


SetPageText(selfpagetext)

Sets the text for the given page.

Parameters:
  • page (int) –
  • text (string) –
Return type:

bool


SetSelection(selfpage)

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

GetSelection

Properties


CurrentPage

See GetCurrentPage


PageCount

See GetPageCount


Selection

See GetSelection and SetSelection

相关文章