AGW Logo

agw_title labelbook

LabelBook and FlatImageBook are a quasi-full generic and owner-drawn implementations of wx.Notebook.


description Description

LabelBook and FlatImageBook are quasi-full implementations of the wx.Notebook, and designed to be a drop-in replacement for wx.Notebook. The API functions are similar so one can expect the function to behave in the same way. LabelBook anf FlatImageBook share their appearance with wx.Toolbook and wx.Listbook, while having more options for custom drawings, label positioning, mouse pointing and so on. Moreover, they retain also some visual characteristics of the Outlook address book.

Some features:

  • They are generic controls;
  • Supports for left, right, top (FlatImageBook only), bottom (FlatImageBook only) book styles;
  • Possibility to draw images only, text only or both (FlatImageBook only);
  • Support for a “pin-button”, that allows the user to shrink/expand the book tab area;
  • Shadows behind tabs (LabelBook only);
  • Gradient shading of the tab area (LabelBook only);
  • Web-like mouse pointing on tabs style (LabelBook only);
  • Many customizable colours (tab area, active tab text, tab borders, active tab, highlight) - LabelBook only.

And much more. See the demo for a quasi-complete review of all the functionalities of LabelBook and FlatImageBook.


usage Usage

Usage example:

import wx
import wx.lib.agw.labelbook as LB

class MyFrame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init__(self, parent, -1, "LabelBook Demo")

        # Possible values for Tab placement are INB_TOP, INB_BOTTOM, INB_RIGHT, INB_LEFT

        notebook = LB.LabelBook(self, -1, agwStyle=LB.INB_FIT_LABELTEXT|LB.INB_LEFT|LB.INB_DRAW_SHADOW|LB.INB_GRADIENT_BACKGROUND)

        pane1 = wx.Panel(notebook)
        pane2 = wx.Panel(notebook)

        imagelist = wx.ImageList(32, 32)
        imagelist.Add(wx.Bitmap("my_bitmap.png", wx.BITMAP_TYPE_PNG))
        notebook.AssignImageList(imagelist)

        notebook.AddPage(pane_1, "Tab1", 1, 0)
        notebook.AddPage(pane_2, "Tab2", 0, 0)


# our normal wxApp-derived class, as usual

app = wx.PySimpleApp()

frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()

app.MainLoop()

This code snippet can be downloaded, see this example script.

Note

Some of the AGW snippets of code in the documentation use images and external files (to create bitmaps or access external data). As these files are not provided in these snippets, you should make the approriate modifications to the code to actually run it.


platforms Supported Platforms

LabelBook and FlatImageBook have been tested on the following platforms:
  • Windows (Windows XP);
  • Linux Ubuntu (Dapper 6.06)

styles Window Styles

This class supports the following window styles:


Window styles for labelbook
Window Styles Hex Value Description
INB_BOTTOM 0x1 Place labels below the page area. Available only for FlatImageBook.
INB_LEFT 0x2 Place labels on the left side. Available only for FlatImageBook.
INB_RIGHT 0x4 Place labels on the right side.
INB_TOP 0x8 Place labels above the page area.
INB_BORDER 0x10 Draws a border around LabelBook or FlatImageBook.
INB_SHOW_ONLY_TEXT 0x20 Shows only text labels and no images. Available only for LabelBook.
INB_SHOW_ONLY_IMAGES 0x40 Shows only tab images and no label texts. Available only for LabelBook.
INB_FIT_BUTTON 0x80 Displays a pin button to show/hide the book control.
INB_DRAW_SHADOW 0x100 Draw shadows below the book tabs. Available only for LabelBook.
INB_USE_PIN_BUTTON 0x200 Displays a pin button to show/hide the book control.
INB_GRADIENT_BACKGROUND 0x400 Draws a gradient shading on the tabs background. Available only for LabelBook.
INB_WEB_HILITE 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for LabelBook.
INB_NO_RESIZE 0x1000 Don’t allow resizing of the tab area.
INB_FIT_LABELTEXT 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
INB_BOLD_TAB_SELECTION 0x4000 Show the selected tab text using a bold font.

events Events Processing

This class processes the following events:


Events processing for labelbook
Event Name Description
EVT_IMAGENOTEBOOK_PAGE_CHANGED Notify client objects when the active page in FlatImageBook or LabelBook has changed.
EVT_IMAGENOTEBOOK_PAGE_CHANGING Notify client objects when the active page in FlatImageBook or LabelBook is about to change.
EVT_IMAGENOTEBOOK_PAGE_CLOSED Notify client objects when a page in FlatImageBook or LabelBook has been closed.
EVT_IMAGENOTEBOOK_PAGE_CLOSING Notify client objects when a page in FlatImageBook or LabelBook is closing.

todos TODOs

  • LabelBook: support IMB_SHOW_ONLY_IMAGES;
  • LabelBook: an option to only draw the border between the controls and the pages so the background colour can flow into the window background.

license License And Version

LabelBook and FlatImageBook are distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 07 Dec 2011, 21.00 GMT

Version 0.6.

Module author: Andrea Gavana <andrea.gavana@gmail.com>


hierarchy Inheritance Diagram

Inheritance diagram for module: labelbook

Inheritance diagram of labelbook.FlatBookBase, labelbook.FlatImageBook, labelbook.ImageContainer, labelbook.ImageContainerBase, labelbook.ImageInfo, labelbook.ImageNotebookEvent, labelbook.LabelBook, labelbook.LabelContainer


svn_main SVN Revisions

A graphical representation of the SVN commits in the last year.

Click on any date in the picture to jump to that particular revision page, containing information about committers, log messages and SVN diffs.

labelbook

Revision Graph For labelbook


2to3 Python 3 Issues (via 2to3)

No issues have been detected by 2to3.py.