wx.Notebook
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 wx.Notebook.AddPage
or wx.Notebook.InsertPage
, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed bywx.Notebook.
NotebookPage is a typedef for wx.Window.
Window Styles
This class supports the following styles:
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
: (WindowsCE
only) Show tabs in a flat style.
The styles wx.NB_LEFT
, wx.RIGHT
and wx.BOTTOM
are not supported under Microsoft Windows XP when using visual themes.
Events Emitted by this Class
Handlers bound for the following event types will receive a wx.BookCtrlEvent parameter.
- EVT_NOTEBOOK_PAGE_CHANGED: The page selection was changed. Processes a
wxEVT_NOTEBOOK_PAGE_CHANGED
event. - EVT_NOTEBOOK_PAGE_CHANGING: The page selection is about to be changed. Processes a
wxEVT_NOTEBOOK_PAGE_CHANGING
event. This event can be vetoed.
Page backgrounds
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 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.
See also
wx.BookCtrl
, wx.BookCtrlEvent, wx.ImageList, Notebook Sample
Class Hierarchy

Control Appearance

wxMSW

wxMAC

wxGTK
Methods Summary
__init__ |
Constructs a notebook control. |
ChangeSelection |
Changes the selection to the given page, returning the previous selection. |
Create |
Creates a notebook control. |
GetPageImage |
Returns the image index for the given page. |
GetPageText |
Returns the string for the given page. |
GetRowCount |
Returns the number of rows in the notebook control. |
GetSelection |
Returns the currently selected page, or NOT_FOUND if none was selected. |
GetThemeBackgroundColour |
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 . |
InsertPage |
Inserts a new page at the specified position. |
SetPadding |
Sets the amount of space around each page’s icon and label, in pixels. |
SetPageImage |
Sets the image index for the given page. |
SetPageText |
Sets the text for the given page. |
SetSelection |
Sets the selection to the given page, returning the previous selection. |
Properties Summary
RowCount |
See GetRowCount |
Selection |
See GetSelection and SetSelection |
ThemeBackgroundColour |
See GetThemeBackgroundColour |
Class API
- class
wx.
Notebook
(BookCtrlBase) -
Possible constructors:
Notebook() Notebook(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
style=0, name=NotebookNameStr)This class represents a notebook control, which manages multiple windows with associated tabs.
Methods
__init__
(self, *args, **kw)-
Overloaded Implementations:
__init__ (self)
Constructs a notebook control.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, name=NotebookNameStr)
Constructs a notebook control.
Note that sometimes you can reduce flicker by passing the
wx.CLIP_CHILDREN
window style.Parameters: - parent (wx.Window) – The parent window. Must be not
None
. - id (wx.WindowID) – The window identifier.
- pos (wx.Point) – The window position.
- size (wx.Size) – The window size.
- style (long) – The window style. See wx.Notebook.
- name (string) – The name of the control.
- parent (wx.Window) – The parent window. Must be not
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.
Parameters: page (int) – Return type: int
Create
(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, name=NotebookNameStr)-
Creates a notebook control.
See wx.Notebook for a description of the parameters.
Parameters: Return type: bool
GetPageImage
(self, nPage)-
Returns the image index for the given page.
Parameters: nPage (int) – Return type: int
GetPageText
(self, nPage)-
Returns the string for the given page.
Parameters: nPage (int) – Return type: string
GetRowCount
(self)-
Returns the number of rows in the notebook control.
Return type: int
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 sowx.BookCtrlEvent.GetSelection
should be used instead in this case.Return type: int
GetThemeBackgroundColour
(self)-
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.
Return type: wx.Colour
InsertPage
(self, index, page, text, select=False, imageId=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
SetPadding
(self, padding)-
Sets the amount of space around each page’s icon and label, in pixels.
Parameters: padding (wx.Size) – Note
The vertical padding cannot be changed in wxGTK.
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
.Parameters: - page (int) –
- image (int) –
Return type: bool
SetPageText
(self, page, text)-
Sets the text for the given page.
Parameters: - page (int) –
- text (string) –
Return type: 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.Parameters: page (int) – Return type: int See also
Properties
RowCount
-
See
GetRowCount
Selection
-
See
GetSelection
andSetSelection
ThemeBackgroundColour
wx.Notebook的更多相关文章
- wx
wx The classes in this module are the most commonly used classes for wxPython, which is why they hav ...
- wx.BookCtrlBase
wx.BookCtrlBase A book control is a convenient way of displaying multiple pages of information, disp ...
- wxpython wx.windows的API
wx.Window is the base class for all windows and represents any visible object on screen. All control ...
- [ZETCODE]wxWidgets教程九:组件专题2
本教程原文链接:http://zetcode.com/gui/wxwidgets/widgetsII/ 翻译:瓶哥 日期:2013年12月15日星期日 邮箱:414236069@qq.com 主页:h ...
- wxWidgets一个界面与数据分离的简单例子
/*************************************************************** * Name: MyApp.h * Purpose: Defines ...
- wxPython Major类
转载自:http://www.yiibai.com/wxpython/wxpython_major_classes.html 原始的 wxWidgets(用C++编写)是一个巨大的类库.GUI类从 ...
- wxpython tab切换页面
最近没事学习下wxpython,发现很少有关于页面切换的demo,这边分享下2中切换的方法.第一种:利用wx.Notebook第二种:利用Sizer布局实现(自己写的),代码没有涉及到什么重构之类的优 ...
- Python 模块之wxpython 的应用
第一个应用程序:“Hello World” 作为传统,我们首先将要写一个小的“Hello World”程序,下面是他的代码: #!/usr/bin/env python import wx app = ...
- wxPython之BoxSizer
1 函数原型 sizer = wx.BoxSizer( integer orient ) 其中的方向(orient)可以是 wx.VERTICAL(垂直) 或 wx.HORIZONTAL(水平). 将 ...
随机推荐
- Oracle EBS-SQL (OM-1):查询订单发货明细.sql
select mtrh.request_number 发货单号, mmt.transaction_date 发货时间, ...
- 转:Memcached常用命令及使用说明
一.存储命令 存储命令的格式: 1 2 <command name> <key> <flags> <exptime> <bytes> < ...
- Linux进程间通信——使用命名管道
在前一篇文章——Linux进程间通信——使用匿名管道中,我们看到了如何使用匿名管道来在进程之间传递数据,同时也看到了这个方式的一个缺陷,就是这些进程都由一个共同的祖先进程启动,这给我们在不相关的的进程 ...
- sql 2000 "无法执行查询,因为一些文件缺少或未注册"的
sql 2000 "无法执行查询,因为一些文件缺少或未注册"的解决办法 在SQL server 2000中打开表查看数据的时候,提示说“无法执行查询,因为一些文件缺少或未注册” 用 ...
- OC基础15:内存管理和自动引用计数
"OC基础"这个分类的文章是我在自学Stephen G.Kochan的<Objective-C程序设计第6版>过程中的笔记. 1.什么是ARC? (1).ARC全名为A ...
- 通过YAJL获取json中的值
这里主要是举例说明一下假设通过yajl获取json中的值. 对于array和object来说,获取的方式略有不同,详细能够參考以下的代码. 我仅仅是从网上搜集信息.知道有这么一种方法.假设还有别的方法 ...
- 泛泰A900 刷4.4专用中文TWRP2.7.1.1版 支持自己主动识别手机版本号(全球首创)
因本人手上的A900S已砖, 所以临时弄不了ROM了, 先上传之前已经弄好的刷4.4专用的新版TWRP recovery 2.7.1.1 这个版本号是我自己定义的,为差别之前公布的2.7.0.0版( ...
- DevExpress VCL 2014.1.2 for C++BUILDER XE6
DevExpress VCL 2014.1.2 for C++BUILDER XE6 1)下载 DevExpress VCL 2014.1.2下载链接:http://pan.baidu.com ...
- Centos升级gcc4.4.7升级gcc4.8手记
本博客来自:http://www.mudbest.com/centos%E5%8D%87%E7%BA%A7gcc4-4-7%E5%8D%87%E7%BA%A7gcc4-8%E6%89%8B%E8%AE ...
- UVA 1611 Crane
题意: 输入一个1-n的排列,要求经过操作将其变换成一个生序序列.操作的规则如下每次操作时,可以选一个长度为偶数的连续区间,交换前一半和后一半. 分析: 假设操作到第i个位置,而i这个数刚好在pos这 ...