FlatNotebook is a full, generic and owner-drawn implementation of Notebook.
FlatNotebook is a full implementation of the Notebook, and designed to be a drop-in replacement for Notebook. The API functions are similar so one can expect the function to behave in the same way.
Some features:
And much more.
Usage example:
import wx
import wx.lib.agw.flatnotebook as fnb
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init(self, parent, -1, "FlatNotebook Demo")
panel = wx.Panel(self)
notebook = fnb.FlatNotebook(panel, -1)
for i in xrange(3):
caption = "Page %d"%(i+1)
notebook.AddPage(self.CreatePage(notebook, caption), caption)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(sizer)
def CreatePage(self, notebook, caption):
'''
Creates a simple :class:`Panel` containing a :class:`TextCtrl`.
:param `notebook`: an instance of `FlatNotebook`;
:param `caption`: a simple label.
'''
p = wx.Panel(notebook)
wx.StaticText(p, -1, caption, (20,20))
wx.TextCtrl(p, -1, "", (20,40), (150,-1))
return p
# our normal wxApp-derived class, as usual
app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
This class supports the following window styles:
Window Styles | Hex Value | Description |
---|---|---|
FNB_VC71 | 0x1 | Use Visual Studio 2003 (VC7.1) style for tabs. |
FNB_FANCY_TABS | 0x2 | Use fancy style - square tabs filled with gradient colouring. |
FNB_TABS_BORDER_SIMPLE | 0x4 | Draw thin border around the page. |
FNB_NO_X_BUTTON | 0x8 | Do not display the ‘X’ button. |
FNB_NO_NAV_BUTTONS | 0x10 | Do not display the right/left arrows. |
FNB_MOUSE_MIDDLE_CLOSES_TABS | 0x20 | Use the mouse middle button for cloing tabs. |
FNB_BOTTOM | 0x40 | Place tabs at bottom - the default is to place them at top. |
FNB_NODRAG | 0x80 | Disable dragging of tabs. |
FNB_VC8 | 0x100 | Use Visual Studio 2005 (VC8) style for tabs. |
FNB_X_ON_TAB | 0x200 | Place ‘X’ close button on the active tab. |
FNB_BACKGROUND_GRADIENT | 0x400 | Use gradients to paint the tabs background. |
FNB_COLOURFUL_TABS | 0x800 | Use colourful tabs (VC8 style only). |
FNB_DCLICK_CLOSES_TABS | 0x1000 | Style to close tab using double click. |
FNB_SMART_TABS | 0x2000 | Use Smart Tabbing, like Alt + Tab on Windows. |
FNB_DROPDOWN_TABS_LIST | 0x4000 | Use a dropdown menu on the left in place of the arrows. |
FNB_ALLOW_FOREIGN_DND | 0x8000 | Allows drag ‘n’ drop operations between different FlatNotebook. |
FNB_HIDE_ON_SINGLE_TAB | 0x10000 | Hides the Page Container when there is one or fewer tabs. |
FNB_DEFAULT_STYLE | 0x10020 | FlatNotebook default style. |
FNB_FF2 | 0x20000 | Use Firefox 2 style for tabs. |
FNB_NO_TAB_FOCUS | 0x40000 | Does not allow tabs to have focus. |
FNB_RIBBON_TABS | 0x80000 | Use the Ribbon Tabs style |
FNB_HIDE_TABS | 0x100000 | Hides the Page Container allowing only keyboard navigation |
FNB_NAV_BUTTONS_WHEN_NEEDED | 0x200000 | Hides the navigation left/right arrows if all tabs fit |
This class processes the following events:
Event Name | Description |
---|---|
EVT_FLATNOTEBOOK_PAGE_CHANGED | Notify client objects when the active page in FlatNotebook has changed. |
EVT_FLATNOTEBOOK_PAGE_CHANGING | Notify client objects when the active page in FlatNotebook is about to change. |
EVT_FLATNOTEBOOK_PAGE_CLOSED | Notify client objects when a page in FlatNotebook has been closed. |
EVT_FLATNOTEBOOK_PAGE_CLOSING | Notify client objects when a page in FlatNotebook is closing. |
EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU | Notify client objects when a pop-up menu should appear next to a tab. |
EVT_FLATNOTEBOOK_PAGE_DROPPED | Notify client objects when a tab has been dropped and re-arranged (on the same notebook) |
EVT_FLATNOTEBOOK_PAGE_DROPPED_FOREIGN | Notify client objects when a tab has been dropped and re-arranged (from a foreign notebook) |
FlatNotebook is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 14 Mar 2012, 21.00 GMT
Version 3.2
AdjustColour | Brighten/darken input colour by percent and adjust alpha channel if needed. |
DrawButton | Draws a FlatNotebook tab. |
FormatColour | Convert the input colour into a valid Colour instance, using whatever typemap |
LightColour | Brighten the input colour by a percentage. |
PaintStraightGradientBox | Draws a gradient coloured box from startColour to endColour. |
RandomColour | Creates a random colour. |
FlatNotebook | The FlatNotebook is a full implementation of the Notebook, and designed to be |
FlatNotebookCompatible | This class is more compatible with the Notebook API, especially regarding |
FlatNotebookDragEvent | This event will be sent when a EVT_FLATNOTEBOOK_PAGE_DRAGGED_FOREIGN is |
FlatNotebookEvent | This events will be sent when a EVT_FLATNOTEBOOK_PAGE_CHANGED, |
FNBDragInfo | Stores all the information to allow drag and drop between different |
FNBDropSource | Give some custom UI feedback during the drag and drop operation in this |
FNBDropTarget | Class used to handle the FlatNotebook.OnDropTarget() method when dragging and |
FNBRenderer | Parent class for the 6 renderers defined: Standard, VC71, Fancy, Firefox 2, |
FNBRendererDefault | This class handles the drawing of tabs using the standard renderer. |
FNBRendererFancy | This class handles the drawing of tabs using the Fancy renderer. |
FNBRendererFirefox2 | This class handles the drawing of tabs using the Firefox 2 renderer. |
FNBRendererMgr | This class represents a manager that handles all the 6 renderers defined |
FNBRendererRibbonTabs | This class handles the drawing of tabs using the Ribbon Tabs renderer. |
FNBRendererVC71 | This class handles the drawing of tabs using the VC71 renderer. |
FNBRendererVC8 | This class handles the drawing of tabs using the VC8 renderer. |
PageContainer | This class acts as a container for the pages you add to FlatNotebook. |
PageInfo | This class holds all the information (caption, image, etc...) belonging to a |
TabNavigatorWindow | This class is used to create a modal dialog that enables Smart Tabbing, |
Brighten/darken input colour by percent and adjust alpha channel if needed.
Parameters: |
|
---|---|
Returns: | The modified colour. |
Draws a FlatNotebook tab.
Parameters: |
|
---|
Convert the input colour into a valid Colour instance, using whatever typemap accepted by wxWidgets/wxPython.
Parameters: | colour – can be an instance of Colour, a 3 or 4 integer tuple, a hex string, a string representing the colour name or None. |
---|---|
Returns: | a valid instance of Colour or None if the input colour was None in the first place. |
Brighten the input colour by a percentage.
Parameters: |
|
---|
Draws a gradient coloured box from startColour to endColour.
Parameters: |
|
---|
Creates a random colour.