wx.aui.AuiNotebook

Inheritance diagram for wx.aui.AuiNotebook:



Description

wx.aui.AuiNotebook is part of the wxAUI class framework.

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.

An effort has been made to try to maintain an API as similar to that of wx.Notebook.

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

A simple example on how to use wx.aui.AuiNotebook:

class TestPanel(wx.Panel):
    """ Simple class example for wx.aui.AuiNotebook. """

    def __init__(self, parent):
        """ Class constructor. """

        wx.Panel.__init__(self, parent, -1)

        # Create the wx.aui.AuiNotebook
        self.nb = wx.aui.AuiNotebook(self)

        # Create a simple text control
        page = wx.TextCtrl(self.nb, -1, "Hello World!", style=wx.TE_MULTILINE)
        # Add the text control as wx.aui.AuiNotebook page
        self.nb.AddPage(page, "Welcome")

        # Add some more pages to the wx.aui.AuiNotebook
        for num in range(1, 5):
            page = wx.TextCtrl(self.nb, -1, "This is page %d" % num, style=wx.TE_MULTILINE)
            self.nb.AddPage(page, "Tab Number %d" % num)

        # Put the wx.aui.AuiNotebook in a sizer and
        # assign the sizer to the main panel
        sizer = wx.BoxSizer()
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(sizer)

# Create a wx.App instance
app = wx.App(0)

# This is our main application frame
frame = wx.Frame(None, -1, "wx.aui.AuiNotebook Sample")
panel = TestPanel(frame)

# Center the frame and show it
frame.CenterOnScreen()
frame.Show()

# Run the MainLoop(), we are done.
app.MainLoop()

Derived From

Known Subclasses

wx.aui.AuiMDIClientWindow

Window Styles

Window Style Description
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_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_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.

Properties Summary

Class API

Methods

__init__(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.aui.AUI_NB_DEFAULT_STYLE)

Constructor, create a wx.aui.AuiNotebook.

Parameters:

  • parent (wx.Window): The parent window.
  • id (int): The window identifier, may be -1.
  • pos (wx.Point): The wx.aui.AuiNotebook position.
  • size (wx.Size): The notebook size.
  • style (long): Window style, see Window Styles.

Returns:

wx.aui.AuiNotebook


AddPage(page, caption, select=False, page=wx.NullBitmap)

Adds a page.

If the select parameter is True, calling this will generate a page change event.

Parameters:


Returns:

bool

See also

InsertPage


AdvanceSelection(forward=True)

Sets the selection to the next or previous page.

Parameters:

  • forward (bool)

Create(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.aui.AUI_NB_DEFAULT_STYLE)

Creates the wx.aui.AuiNotebook.

Parameters:

  • parent (wx.Window): The parent window.
  • id (int): The window identifier, may be -1.
  • pos (wx.Point): The wx.aui.AuiNotebook position.
  • size (wx.Size): The notebook size.
  • style (long): Window style, see Window Styles.

Returns:

bool


DeletePage(page)

Deletes a page at the given index.

Calling this method will generate a page change event.

Parameters:

  • page (long)

Returns:

bool


GetArtProvider()

Returns the associated art provider.


Returns:

wx.aui.AuiTabArt


GetAuiManager()
No docstrings available for this method.

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

Returns:

int


GetPage(page_idx)

Returns the page specified by the given index.

Parameters:

  • page_idx (long)

Returns:

wx.Window


GetPageBitmap(page)

Returns the tab bitmap for the page.

Parameters:

  • page (long)

Returns:

wx.Bitmap


GetPageCount()

Returns the number of pages in the notebook.


Returns:

long


GetPageIndex(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:


Returns:

int


GetPageText(page)

Returns the tab label for the page.

Parameters:

  • page (long)

Returns:

string


GetSelection()

Returns the currently selected page.


Returns:

int


GetTabCtrlHeight()

Returns the height of the tab control.


Returns:

int


InsertPage(page_idx, page, caption, select=False, bitmap=wx.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:


Returns:

bool

See also

AddPage


RemovePage(page)

Removes a page, without deleting the window pointer.

Parameters:

  • page (long)

Returns:

bool


SetArtProvider(art)

Sets the art provider to be used by the notebook.

Parameters:


SetMeasuringFont(font)

Sets the font for measuring tab labels.

Parameters:


SetNormalFont(font)

Sets the font for drawing unselected tab labels.

Parameters:


SetPageBitmap(page, bitmap)

Sets the bitmap for the page.

To remove a bitmap from the tab caption, pass wx.NullBitmap.

Parameters:


Returns:

bool


SetPageText(page, text)

Sets the tab label for the page.

Parameters:

  • page (long)
  • text (string)

Returns:

bool


SetSelectedFont(font)

Sets the font for drawing selected tab labels.

Parameters:


SetSelection(new_page)

Sets the page selection.

Calling this method will generate a page change event.

Parameters:

  • new_page (long)

Returns:

long


SetTabCtrlHeight(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(size)

Ensures that all tabs will have the same height, even if some tabs don’t have bitmaps.

Passing wx.DefaultSize to this function will instruct the control to use dynamic tab height, which is the default behaviour. Under the default behaviour, when a tab with a large bitmap is added, the tab control’s height will automatically increase to accommodate the larger bitmap.

Parameters:


ShowWindowMenu()

Shows the window menu for the active tab control associated with this notebook, and returns True if a selection was made.


Returns:

bool


Split(page, direction)

Split performs a split operation programmatically.

Parameters:

  • page (int): Indicates the page that will be split off. This page will also become the active page after the split.
  • direction (int): Specifies where the pane should go, it should be one of the following: wx.TOP, wx.BOTTOM, wx.LEFT, or wx.RIGHT.

Properties

PageCount
See GetPageCount
Selection
See GetSelection and SetSelection