Inheritance diagram for wx.Notebook:
This class represents a notebook control, which manages multiple windows with associated tabs.
To use the class, create a wx.Notebook object and call AddPage or InsertPage, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed by wx.Notebook.
wx.NotebookPage is a typedef for wx.Window.
See also
On Windows XP, the default theme paints a gradient on the notebook’s pages. If you wish to suppress this theme, for aesthetic or performance reasons, there are three ways of doing it. You can use wx.NB_NOPAGETHEME to disable themed drawing for a particular notebook, you can call wx.SystemOptions.SetOption to disable it for the whole application, or you can disable it for individual pages by using SetBackgroundColour.
To disable themed pages globally:
wx.SystemOptions.SetOption("msw.notebook.themed-background", 0)
Set the value to 1 to enable it again.
To give a single page a solid background that more or less fits in with the overall theme, use:
col = notebook.GetThemeBackgroundColour()
if col.IsOk():
page.SetBackgroundColour(col)
On platforms other than Windows, or if the application is not using Windows themes, GetThemeBackgroundColour will return an uninitialised colour object, and the above code will therefore work on all platforms.
Window Style | Description |
---|---|
wx.NB_TOP | Place tabs on the top side. |
wx.NB_LEFT | Place tabs on the left side. |
wx.NB_RIGHT | Place tabs on the right side. |
wx.NB_BOTTOM | Place tabs under instead of above the notebook pages. |
wx.NB_FIXEDWIDTH | (Windows only) All tabs will have same width. |
wx.NB_MULTILINE | (Windows only) There can be several rows of tabs. |
wx.NB_NOPAGETHEME | (Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance. |
wx.NB_FLAT | (Windows CE only) Show tabs in a flat style. |
Event Name | Description |
---|---|
wx.EVT_NOTEBOOK_PAGE_CHANGED(id, func) | The page selection was changed. Processes a wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event. |
wx.EVT_NOTEBOOK_PAGE_CHANGING(id, func) | The page selection is about to be changed. Processes a wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event. This event can be vetoed. |
Constructor.
Parameters:
Returns:
Adds a new page.
Parameters:
Returns:
bool
Note
Do not delete the page, it will be deleted by the notebook.
Note
The call to this function may generate the page changing events.
See also
Note
The call to this function generates the page changing events.
Sets the image list for the page control and takes ownership of the list.
Parameters:
See also
Changes the selection for the given page, returning the previous selection.
Parameters:
Returns:
int
Note
The call to this function does not generate the page changing events. This is the only difference with SetSelection.
Deletes all pages.
Returns:
bool
Deletes the specified page, and the associated window.
Parameters:
Returns:
bool
Note
The call to this function generates the page changing events.
Returns the associated image list.
Returns:
See also
Returns the window at the given page position.
Parameters:
Returns:
Returns the number of pages in the notebook control.
Returns:
long
Returns the image index for the given page.
Parameters:
Returns:
int
Returns the string for the given page.
Parameters:
Returns:
string
Returns the number of rows in the notebook control.
Returns:
int
Returns the currently selected page, or -1 if none was selected.
Returns:
int
Note
Note that this method may return either the previously or newly selected page when called from the wx.EVT_NOTEBOOK_PAGE_CHANGED handler depending on the platform and so wx.NotebookEvent.GetSelection should be used instead in this case.
If running under Windows and themes are enabled for the application, this function returns a suitable colour for painting the background of a notebook page, and can be passed to SetBackgroundColour. Otherwise, an uninitialised colour will be returned.
Returns:
Returns the page/tab which is hit, and flags indicating where using wx.NB_HITTEST flags.
The return value tab is one of the following values:
Tab HitTest Flags | Description |
---|---|
wx.BK_HITTEST_NOWHERE | There was no tab under this point. |
wx.BK_HITTEST_ONICON | The point was over an icon (currently wxMSW only). |
wx.BK_HITTEST_ONLABEL | The point was over a label (currently wxMSW only). |
wx.BK_HITTEST_ONITEM | The point was over an item, but not on the label or icon. |
wx.BK_HITTEST_ONPAGE | The point was over a currently selected page, not over any tab. Note that this flag is present only if wx.NOT_FOUND is returned. |
Parameters:
Returns:
(tab, where)
Inserts a new page at the specified position.
Parameters:
Returns:
bool
Note
Do not delete the page, it will be deleted by the notebook.
See also
Deletes the specified page, without deleting the associated window.
Parameters:
Returns:
bool
Parameters:
Parameters:
Returns:
bool
Sets the image list for the page control. It does not take ownership of the image list, you must delete it yourself.
Parameters:
See also
Sets the amount of space around each page’s icon and label, in pixels.
Parameters:
Note
The vertical padding cannot be changed in wxGTK.
Sets the image index for the given page. image is an index into the image list which was set with SetImageList.
Parameters:
Returns:
bool
Sets the width and height of the pages.
Parameters:
Note
This method is currently not implemented for wxGTK.
Sets the text for the given page.
Parameters:
Returns:
bool
Sets the selection for the given page, returning the previous selection.
Parameters:
Warning
This function is deprecated and should not be used in new code. Please use the ChangeSelection function instead.
Note
The call to this function generates the page changing events.
See also