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: (Windows CE only) Show tabs in a flat style.

The styles wx.NB_LEFTwx.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.BookCtrlEventwx.ImageList, Notebook Sample

 

 Class Hierarchy

 Inheritance diagram for class Notebook:

 

 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.
 

 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.


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(selfparentid=ID_ANYpos=DefaultPositionsize=DefaultSizestyle=0name=NotebookNameStr)

Creates a notebook control.

See wx.Notebook for a description of the parameters.

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

bool


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


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 so wx.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(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


SetPadding(selfpadding)

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


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


RowCount

See GetRowCount


Selection

See GetSelection and SetSelection


ThemeBackgroundColour

See GetThemeBackgroundColour

wx.Notebook的更多相关文章

  1. wx

    wx The classes in this module are the most commonly used classes for wxPython, which is why they hav ...

  2. wx.BookCtrlBase

    wx.BookCtrlBase A book control is a convenient way of displaying multiple pages of information, disp ...

  3. wxpython wx.windows的API

    wx.Window is the base class for all windows and represents any visible object on screen. All control ...

  4. [ZETCODE]wxWidgets教程九:组件专题2

    本教程原文链接:http://zetcode.com/gui/wxwidgets/widgetsII/ 翻译:瓶哥 日期:2013年12月15日星期日 邮箱:414236069@qq.com 主页:h ...

  5. wxWidgets一个界面与数据分离的简单例子

    /*************************************************************** * Name: MyApp.h * Purpose: Defines ...

  6. wxPython Major类

    转载自:http://www.yiibai.com/wxpython/wxpython_major_classes.html   原始的 wxWidgets(用C++编写)是一个巨大的类库.GUI类从 ...

  7. wxpython tab切换页面

    最近没事学习下wxpython,发现很少有关于页面切换的demo,这边分享下2中切换的方法.第一种:利用wx.Notebook第二种:利用Sizer布局实现(自己写的),代码没有涉及到什么重构之类的优 ...

  8. Python 模块之wxpython 的应用

    第一个应用程序:“Hello World” 作为传统,我们首先将要写一个小的“Hello World”程序,下面是他的代码: #!/usr/bin/env python import wx app = ...

  9. wxPython之BoxSizer

    1 函数原型 sizer = wx.BoxSizer( integer orient ) 其中的方向(orient)可以是 wx.VERTICAL(垂直) 或 wx.HORIZONTAL(水平). 将 ...

随机推荐

  1. 如何设置 Internal 类,方法,属性对其他项目可见

    internal 修饰符时程序集内部其他类可见.但对程序集外的类不可见,这样就很好的封装了可见性. 但是,我们也许会碰到类似的情况,特别是基于已有代码开发新的代码时,你会发现很多 internal 的 ...

  2. 学习linux之用户-文件-权限操作

    添加用户组 添加 gropuadd 用户组名 修改 groupmod 用户组名 删除 groupdel 用户组名 添加用户 添加 useradd 用户名 设密码 passwd 密码 删除 userde ...

  3. thinkphp中的where()方法

    where方法的用法是ThinkPHP查询语言的精髓,也是ThinkPHP ORM的重要组成部分和亮点所在,可以完成包括普通查询.表达式查询.快捷查询.区间查询.组合查询在内的查询操作.where方法 ...

  4. Android中ListView无法点击

    Android中ListView无法点击 转自:http://xqjay19910131-yahoo-cn.iteye.com/blog/1319502   问题描述: ListView中Item加入 ...

  5. Android的读写文件权限

    设置文件生成的权限: public static boolean saveInfo( Context context, String userName, String userPass, int mo ...

  6. 全国计算机等级考试二级教程-C语言程序设计_第3章_顺序结构

    1输入两个整数给变量x和y:然后输出x和y:在交换x和y中的值后,在输出x和y. #include <stdio.h> main() { int x, y, t; printf(" ...

  7. Java面向对象面试案例

  8. Hadoop--初识Hadoop

    什么是Hadoop? 搞什么东西之前,第一步是要知道What(是什么),然后是Why(为什么),最后才是How(怎么做).但很多开发的朋友在做了多年项目以后,都习惯是先How,然后What,最后才是W ...

  9. 卓尼斯ZT-180评測

    卓尼斯ZT-180评測    ——正在出差途中,用10”上网本发帖,没有拍照,且写得冲忙,不妥之处见谅. 一.採购 1.因外出旅游,不想带那台14"笔记本,所以想买一台平板电脑.当时,选择的 ...

  10. js函数设计原则

    一般认为函数指具有返回值的子程序,过程指没有返回值的子程序.C++中把所有子程序成为函数,其实那些返回值为void的 函数在语义上也是过程.函数与过程的区别更多是语义上的区别,而不是语法的区别. 语言 ...