Custom Controls → FlatNotebook

overview = """\

The FlatNotebook is a full implementation 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.

Some features:
The buttons are highlighted a la Firefox style
The scrolling is done for bulks of tabs (so, the scrolling is faster and better)
The buttons area is never overdrawn by tabs (unlike many other implementations I saw)
It is a generic control
Currently there are 4 differnt styles - VC8, VC 71, Standard and Fancy
Mouse middle click can be used to close tabs
A function to add right click menu for tabs (simple as SetRightClickMenu)
All styles has bottom style as well (they can be drawn in the bottom of screen)
An option to hide 'X' button or navigation buttons (separately)
Gradient coloring of the selected tabs and border
Support for drag 'n' drop of tabs, both in the same notebook or to another notebook
Possibility to have closing button on the active tab directly
Support for disabled tabs
Colours for active/inactive tabs, and captions
Background of tab area can be painted in gradient (VC8 style only)
Colourful tabs - a random gentle colour is generated for each new tab (very cool, VC8 style only)
And much more.

License And Version:

FlatNotebook Is Freeware And Distributed Under The wxPython License.

Latest Revision: Andrea Gavana @ 12 Oct 2006, 20.00 GMT

Version 2.0.
"""
   
   
import wx
import wx.lib.flatnotebook as flatnotebook
import os
import os.path
  
  
class Frame(wx.Frame):

def __init__(
  self, parent=None, id=wx.ID_ANY, title='wx.lib.flatnotebook', pos=wx.DefaultPosition,
  size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
  ):
  
  wx.Frame.__init__(self, parent, id, title, pos, size, style)
  self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
  
  panel = wx.Panel(self, wx.ID_ANY)
  
  pageTitles = ['C', 'C++', 'Python', 'Java', 'Perl', 'JavaScript', 'C#', 'AWK']
  imageList = wx.ImageList(16, 16)
  for num in range(len(pageTitles)):
   imageList.Add(wx.Bitmap(os.path.join(os.getcwd(), '16x16', str(num)+'.bmp'), wx.BITMAP_TYPE_BMP))
  
  flatNotebook1 = flatnotebook.FlatNotebook(panel, wx.ID_ANY,
              style=flatnotebook.FNB_DCLICK_CLOSES_TABS |
              flatnotebook.FNB_COLORFUL_TABS |
              flatnotebook.FNB_X |
              flatnotebook.FNB_X_ON_TAB |
              flatnotebook.FNB_FANCY_TABS |
              flatnotebook.FNB_SMART_TABS)
              # reference document for more flags
  
  flatNotebook1.SetImageList(imageList)
  for id, title in enumerate(pageTitles):
   textCtrl = wx.TextCtrl(flatNotebook1, wx.ID_ANY, 'This is the page about %s\n\n%s!' % (title, overview), style=wx.TE_MULTILINE)
   flatNotebook1.AddPage(textCtrl, title, imageId=id)
  
  flatNotebook2 = flatnotebook.FlatNotebook(panel, wx.ID_ANY)
  flatNotebook2.SetImageList(imageList)
  for id, title in enumerate(pageTitles):
   textCtrl = wx.TextCtrl(flatNotebook2, wx.ID_ANY, 'This is the page about %s\n\n%s!' % (title, overview), style=wx.TE_MULTILINE)
   flatNotebook2.AddPage(textCtrl, title, imageId=id)
  
  sizer = wx.BoxSizer(wx.VERTICAL)
  sizer.Add(flatNotebook1, 6, wx.EXPAND)
  sizer.AddSpacer((10, 10))
  sizer.Add(flatNotebook2, 2, wx.EXPAND)
  panel.SetSizer(sizer)
  
  
def TestFrame():
app = wx.PySimpleApp()
frame = Frame(size=(640, 480))
frame.Centre()
frame.Show()
app.MainLoop()


if __name__ == '__main__':
TestFrame()