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

 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.


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

时间: 2024-10-27 06:38:18

wx.Notebook的相关文章

wxpython wx.windows的API

wx.Window is the base class for all windows and represents any visible object on screen. All controls, top level windows and so on are windows. Sizers and device contexts are not, however, as they don't appear on screen themselves. Please note that a

[译] 开始使用 wxPython [Getting started with wxPython]

原文:http://wiki.wxpython.org/Getting%20Started 1. 第一个应用程序:Hello World 按照“国际惯例”,我们先写一个“Hello World”的应用程序,下面是代码: 1 #!/usr/bin/env python 2 import wx 3 4 app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window. 5 frame = wx.Frame

图书数据库操作界面升级

今年年初,我写了一篇名为<图书管理库以及操作界面>的文章(链接:http://blog.csdn.net/qq_32897527/article/details/50493313),但是由于技术问题,导致程序不是很优化,界面也不是很友好.最近得空稍微研究了下,对界面进行了升级. 1.使用表格进行数据项显示 升级前 升级后 #coding:gbk import wx,sqlite3 import wx.lib.sheet as sheet class find(wx.Frame): def lo

wxpython 的应用

第一个应用程序:"Hello World" 作为传统,我们首先将要写一个小的"Hello World"程序,下面是他的代码: #!/usr/bin/env python import wx   app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window. frame = wx.Frame(None, wx.ID_ANY, "Hello World"

初学者需要IPython 与 Jupyter Notebook 吗?

ipython 是 jupyter notebook的前身并拥有ipython的全部功能 jupyter拥有 cell, markdown 整合的功能, 能同时运行代码, 而且是多组的. 同时也可以插入markdown这种多功能注释 包括图片. 写教程,写博客非常一流. 而且还可以上传到jupyterhub-据说要自己搭建 对于初学者来说, jupyter毕竟是一个web应用, 存储文件有不稳定的地方. 建议还是使用pycharm这类的软件编写代码.

微信小程序开发之页面wxml里面实现循环 wx:for

js代码: Page({ data:{ upploadimagelist:{},    //上报图片列表 js数组 }}) var uploadimageObj=JSON.parse(res.data.feedback.fbimages);  //将后台传过来的json字符串转换为js数组,res为wx.request({})请求成功的返回对象 wxml代码:<view wx:for="{{upploadimagelist}}" wx:key="id">

微信小程序开发之三元运算符代替wx.if/wx.else

直接上代码 实现功能为:当fbphotoFirst为空时,src路径为"pic/信息反馈1-1_14.png",并且点击事件uploadfbphotoFirst有效,否则为路径fbphotoFirst,此时点击事件uploadfbphotoFirst无效,uploadfbphotoFirst为上传图片的方法,即上传图片成功后不支持修改 <image class="uploadimageclass"   bindtap="{{fbphotoFirst=

jupyter notebook在网页上显示作图

今天尝试使用jupyter notebook作图像展示工具时,发现用matplotlib所作的图像会自动启动一个图像展示窗口,无法显示在网页上,而我的初衷是使用jupyter notebook做图像即时呈现及存储(有点类似PPT作图). 随机生成一批正弦数据: import numpy as np import matplotlib.pyplot as plt x=np.arange(10) y=np.sin(x) plt.plot(x,y) plt.show() 使用%matplotlib命令

Jupyter Notebook 快捷键

Jupyter Notebook 的快捷键 Jupyter Notebook 有两种键盘输入模式.编辑模式,允许你往单元中键入代码或文本:这时的单元框线是绿色的.命令模式,键盘输入运行程序命令:这时的单元框线是灰色. 命令模式 (按键 Esc 开启) Ctrl-Enter : 运行本单元 Enter : 转入编辑模式 Shift-Enter : 运行本单元,选中下个单元 Alt-Enter : 运行本单元,在其下插入新单元 Y : 单元转入代码状态 M :单元转入markdown状态 R : 单