wx.aui.AuiNotebook is part of the AUI
class framework, which represents a notebook control, managing multiple windows with associated tabs.
See also AUI Overview.
wx.aui.AuiNotebook is a notebook control which implements many features common in applications with dockable panes. Specifically, wx.aui.AuiNotebook implements functionality which allows the user to rearrange tab order via drag-and-drop, split the tab window into many different splitter configurations, and toggle through different themes to customize the control’s look and feel.
The default theme that is used is wx.aui.AuiDefaultTabArt, which provides a modern, glossy look and feel. The theme can be changed by calling wx.aui.AuiNotebook.SetArtProvider
.
This class supports the following styles:
wx.aui.AUI_NB_DEFAULT_STYLE
: Defined as wx.aui.AUI_NB_TOP
| wx.aui.AUI_NB_TAB_SPLIT
| wx.aui.AUI_NB_TAB_MOVE
| wx.aui.AUI_NB_SCROLL_BUTTONS
| wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
| wx.aui.AUI_NB_MIDDLE_CLICK_CLOSE
.wx.aui.AUI_NB_TAB_SPLIT
: Allows the tab control to be split by dragging a tab.wx.aui.AUI_NB_TAB_MOVE
: Allows a tab to be moved horizontally by dragging.wx.aui.AUI_NB_TAB_EXTERNAL_MOVE
: Allows a tab to be moved to another tab control.wx.aui.AUI_NB_TAB_FIXED_WIDTH
: With this style, all tabs have the same width.wx.aui.AUI_NB_SCROLL_BUTTONS
: With this style, left and right scroll buttons are displayed.wx.aui.AUI_NB_WINDOWLIST_BUTTON
: With this style, a drop-down list of windows is available.wx.aui.AUI_NB_CLOSE_BUTTON
: With this style, a close button is available on the tab bar.wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
: With this style, the close button is visible on the active tab.wx.aui.AUI_NB_CLOSE_ON_ALL_TABS
: With this style, the close button is visible on all tabs.wx.aui.AUI_NB_MIDDLE_CLICK_CLOSE
: With this style, middle click on a tab closes the tab.wx.aui.AUI_NB_TOP
: With this style, tabs are drawn along the top of the notebook.wx.aui.AUI_NB_BOTTOM
: With this style, tabs are drawn along the bottom of the notebook.Handlers bound for the following event types will receive a wx.aui.AuiNotebookEvent parameter.
wxEVT_AUINOTEBOOK_PAGE_CLOSE
event.wxEVT_AUINOTEBOOK_PAGE_CLOSED
event.wxEVT_AUINOTEBOOK_PAGE_CHANGED
event.wxEVT_AUINOTEBOOK_PAGE_CHANGING
event. This event can be vetoed.wxEVT_AUINOTEBOOK_BUTTON
event.wxEVT_AUINOTEBOOK_BEGIN_DRAG
event.wxEVT_AUINOTEBOOK_END_DRAG
event.wxEVT_AUINOTEBOOK_DRAG_MOTION
event.wxEVT_AUINOTEBOOK_ALLOW_DND
event. This event must be specially allowed.wxEVT_AUINOTEBOOK_DRAG_DONE
event.wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN
event.wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP
event.wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN
event.wxEVT_AUINOTEBOOK_TAB_RIGHT_UP
event.wxEVT_AUINOTEBOOK_BG_DCLICK
event.__init__ |
Default constructor. |
AddPage |
Adds a page. |
AdvanceSelection |
Sets the selection to the next or previous page. |
ChangeSelection |
Changes the selection for the given page, returning the previous selection. |
Create |
Creates the notebook window. |
DeleteAllPages |
Deletes all pages. |
DeletePage |
Deletes a page at the given index. |
GetArtProvider |
Returns the associated art provider. |
GetCurrentPage |
Returns the currently selected page or None . |
GetHeightForPageHeight |
Returns the desired height of the notebook for the given page height. |
GetPage |
Returns the page specified by the given index. |
GetPageBitmap |
Returns the tab bitmap for the page. |
GetPageCount |
Returns the number of pages in the notebook. |
GetPageImage |
Returns the image index for the given page. |
GetPageIndex |
Returns the page index for the specified window. |
GetPageText |
Returns the tab label for the page. |
GetPageToolTip |
Returns the tooltip for the tab label of the page. |
GetSelection |
Returns the currently selected page. |
GetTabCtrlHeight |
Returns the height of the tab control. |
InsertPage |
InsertPage is similar to AddPage, but allows the ability to specify the insert location. |
RemovePage |
Removes a page, without deleting the window pointer. |
SetArtProvider |
Sets the art provider to be used by the notebook. |
SetFont |
Sets the font for drawing the tab labels, using a bold version of the font for selected tab labels. |
SetMeasuringFont |
Sets the font for measuring tab labels. |
SetNormalFont |
Sets the font for drawing unselected tab labels. |
SetPageBitmap |
Sets the bitmap for the page. |
SetPageImage |
Sets the image index for the given page. |
SetPageText |
Sets the tab label for the page. |
SetPageToolTip |
Sets the tooltip displayed when hovering over the tab label of the page. |
SetSelectedFont |
Sets the font for drawing selected tab labels. |
SetSelection |
Sets the page selection. |
SetTabCtrlHeight |
Sets the tab height. |
SetUniformBitmapSize |
Ensure that all tabs have the same height, even if some of them don’t have bitmaps. |
ShowWindowMenu |
Shows the window menu for the active tab control associated with this notebook, and returns True if a selection was made. |
Split |
Split performs a split operation programmatically. |
ArtProvider |
See GetArtProvider and SetArtProvider |
CurrentPage |
See GetCurrentPage |
PageCount |
See GetPageCount |
Selection |
See GetSelection and SetSelection |
TabCtrlHeight |
See GetTabCtrlHeight and SetTabCtrlHeight |
wx.aui.
AuiNotebook
(BookCtrlBase)¶Possible constructors:
AuiNotebook()
AuiNotebook(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
style=AUI_NB_DEFAULT_STYLE)
AuiNotebook is part of the AUI
class framework, which represents a
notebook control, managing multiple windows with associated tabs.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=AUI_NB_DEFAULT_STYLE)
Constructor.
Creates a AuiNotebok control.
Parameters: |
---|
AddPage
(self, *args, **kw)¶AddPage (self, page, caption, select=False, bitmap=NullBitmap)
Adds a page.
If the select
parameter is True
, calling this will generate a page change event.
Parameters: | |
---|---|
Return type: | bool |
AddPage (self, page, text, select, imageId)
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: |
|
---|---|
Return type: | bool |
Returns: |
|
New in version 2.9.3.
Note
Do not delete the page, it will be deleted by the book control.
See also
AdvanceSelection
(self, forward=True)¶Sets the selection to the next or previous page.
Parameters: | forward (bool) – |
---|
ChangeSelection
(self, n)¶Changes the selection for 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: | n (int) – |
---|---|
Return type: | int |
New in version 2.9.3.
Create
(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0)¶Creates the notebook window.
Parameters: | |
---|---|
Return type: | bool |
DeleteAllPages
(self)¶Deletes all pages.
Return type: | bool |
---|
New in version 2.9.3.
DeletePage
(self, page)¶Deletes a page at the given index.
Calling this method will generate a page change event.
Parameters: | page (int) – |
---|---|
Return type: | bool |
GetArtProvider
(self)¶Returns the associated art provider.
Return type: | wx.aui.AuiTabArt |
---|
GetCurrentPage
(self)¶Returns the currently selected page or None
.
Return type: | Window |
---|
New in version 2.9.3.
GetHeightForPageHeight
(self, pageHeight)¶Returns the desired height of the notebook for the given page height.
Use this to fit the notebook to a given page size.
Parameters: | pageHeight (int) – |
---|---|
Return type: | int |
GetPage
(self, page_idx)¶Returns the page specified by the given index.
Parameters: | page_idx (int) – |
---|---|
Return type: | Window |
GetPageBitmap
(self, page)¶Returns the tab bitmap for the page.
Parameters: | page (int) – |
---|---|
Return type: | Bitmap |
GetPageCount
(self)¶Returns the number of pages in the notebook.
Return type: | int |
---|
GetPageImage
(self, nPage)¶Returns the image index for the given page.
Parameters: | nPage (int) – |
---|---|
Return type: | int |
GetPageIndex
(self, page_wnd)¶Returns the page index for the specified window.
If the window is not found in the notebook, wx.NOT_FOUND
is returned.
Parameters: | page_wnd (wx.Window) – |
---|---|
Return type: | int |
GetPageText
(self, page)¶Returns the tab label for the page.
Parameters: | page (int) – |
---|---|
Return type: | string |
GetPageToolTip
(self, pageIdx)¶Returns the tooltip for the tab label of the page.
Parameters: | pageIdx (int) – |
---|---|
Return type: | string |
New in version 2.9.4.
GetSelection
(self)¶Returns the currently selected page.
Return type: | int |
---|
GetTabCtrlHeight
(self)¶Returns the height of the tab control.
Return type: | int |
---|
InsertPage
(self, *args, **kw)¶InsertPage (self, page_idx, page, caption, select=False, bitmap=NullBitmap)
InsertPage
is similar to AddPage, but allows the ability to specify the insert location.
If the select
parameter is True
, calling this will generate a page change event.
Parameters: | |
---|---|
Return type: | bool |
InsertPage (self, index, page, text, select, imageId)
Inserts a new page at the specified position.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
New in version 2.9.3.
Note
Do not delete the page, it will be deleted by the book control.
See also
RemovePage
(self, page)¶Removes a page, without deleting the window pointer.
Parameters: | page (int) – |
---|---|
Return type: | bool |
SetArtProvider
(self, art)¶Sets the art provider to be used by the notebook.
Parameters: | art (wx.aui.AuiTabArt) – |
---|
SetFont
(self, font)¶Sets the font for drawing the tab labels, using a bold version of the font for selected tab labels.
Parameters: | font (wx.Font) – |
---|---|
Return type: | bool |
SetNormalFont
(self, font)¶Sets the font for drawing unselected tab labels.
Parameters: | font (wx.Font) – |
---|
SetPageBitmap
(self, page, bitmap)¶Sets the bitmap for the page.
To remove a bitmap from the tab caption, pass NullBitmap.
Parameters: |
|
---|---|
Return type: | bool |
SetPageImage
(self, n, imageId)¶Sets the image index for the given page.
image is an index into the image list which was set with SetImageList
.
Parameters: |
|
---|---|
Return type: | bool |
New in version 2.9.3.
SetPageText
(self, page, text)¶Sets the tab label for the page.
Parameters: |
|
---|---|
Return type: | bool |
SetPageToolTip
(self, page, text)¶Sets the tooltip displayed when hovering over the tab label of the page.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
New in version 2.9.4.
SetSelectedFont
(self, font)¶Sets the font for drawing selected tab labels.
Parameters: | font (wx.Font) – |
---|
SetSelection
(self, new_page)¶Sets the page selection.
Calling this method will generate a page change event.
Parameters: | new_page (int) – |
---|---|
Return type: | int |
SetTabCtrlHeight
(self, height)¶Sets the tab height.
By default, the tab control height is calculated by measuring the text height and bitmap sizes on the tab captions. Calling this method will override that calculation and set the tab control to the specified height parameter. A call to this method will override any call to SetUniformBitmapSize
.
Specifying -1 as the height will return the control to its default auto-sizing behaviour.
Parameters: | height (int) – |
---|
SetUniformBitmapSize
(self, size)¶Ensure that all tabs have the same height, even if some of them don’t have bitmaps.
Passing wx.DefaultSize
as size undoes the effect of a previous call to this function and instructs the control to use dynamic tab height.
Parameters: | size (wx.Size) – |
---|
ShowWindowMenu
(self)¶Shows the window menu for the active tab control associated with this notebook, and returns True
if a selection was made.
Return type: | bool |
---|
Split
(self, page, direction)¶Split performs a split operation programmatically.
The argument page indicates the page that will be split off. This page will also become the active page after the split.
The direction argument specifies where the pane should go, it should be one of the following: wx.TOP
, wx.BOTTOM
, wx.LEFT
, or wx.RIGHT
.
Parameters: |
|
---|
ArtProvider
¶See GetArtProvider
and SetArtProvider
CurrentPage
¶See GetCurrentPage
PageCount
¶See GetPageCount
Selection
¶See GetSelection
and SetSelection
TabCtrlHeight
¶See GetTabCtrlHeight
and SetTabCtrlHeight