Add FlatNotebook

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41643 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-10-05 22:24:18 +00:00
parent ebd9ec2931
commit 6cb4f153c3
9 changed files with 4887 additions and 0 deletions

View File

@@ -0,0 +1,693 @@
import wx
import wx.lib.flatnotebook as fnb
import random
import images
#----------------------------------------------------------------------
def GetMondrianData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
\xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
\x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
\x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82'
def GetMondrianBitmap():
return wx.BitmapFromImage(GetMondrianImage())
def GetMondrianImage():
import cStringIO
stream = cStringIO.StringIO(GetMondrianData())
return wx.ImageFromStream(stream)
def GetMondrianIcon():
icon = wx.EmptyIcon()
icon.CopyFromBitmap(GetMondrianBitmap())
return icon
#----------------------------------------------------------------------
MENU_EDIT_DELETE_ALL = wx.ID_HIGHEST + 1000
MENU_EDIT_ADD_PAGE = MENU_EDIT_DELETE_ALL + 1
MENU_EDIT_DELETE_PAGE = MENU_EDIT_DELETE_ALL + 2
MENU_EDIT_SET_SELECTION = MENU_EDIT_DELETE_ALL + 3
MENU_EDIT_ADVANCE_SELECTION_FWD = MENU_EDIT_DELETE_ALL + 4
MENU_EDIT_ADVANCE_SELECTION_BACK = MENU_EDIT_DELETE_ALL + 5
MENU_SET_ALL_TABS_SHAPE_ANGLE = MENU_EDIT_DELETE_ALL + 6
MENU_SHOW_IMAGES = MENU_EDIT_DELETE_ALL + 7
MENU_USE_VC71_STYLE = MENU_EDIT_DELETE_ALL + 8
MENU_USE_DEFAULT_STYLE = MENU_EDIT_DELETE_ALL + 9
MENU_USE_FANCY_STYLE = MENU_EDIT_DELETE_ALL + 10
MENU_SELECT_GRADIENT_COLOR_FROM = MENU_EDIT_DELETE_ALL + 11
MENU_SELECT_GRADIENT_COLOR_TO = MENU_EDIT_DELETE_ALL + 12
MENU_SELECT_GRADIENT_COLOR_BORDER = MENU_EDIT_DELETE_ALL + 13
MENU_SET_PAGE_IMAGE_INDEX = MENU_EDIT_DELETE_ALL + 14
MENU_HIDE_X = MENU_EDIT_DELETE_ALL + 15
MENU_HIDE_NAV_BUTTONS = MENU_EDIT_DELETE_ALL + 16
MENU_USE_MOUSE_MIDDLE_BTN = MENU_EDIT_DELETE_ALL + 17
MENU_DRAW_BORDER = MENU_EDIT_DELETE_ALL + 18
MENU_USE_BOTTOM_TABS = MENU_EDIT_DELETE_ALL + 19
MENU_ENABLE_TAB = MENU_EDIT_DELETE_ALL + 20
MENU_DISABLE_TAB = MENU_EDIT_DELETE_ALL + 21
MENU_ENABLE_DRAG_N_DROP = MENU_EDIT_DELETE_ALL + 22
MENU_DCLICK_CLOSES_TAB = MENU_EDIT_DELETE_ALL + 23
MENU_USE_VC8_STYLE = MENU_EDIT_DELETE_ALL + 24
MENU_SET_ACTIVE_TEXT_COLOR = MENU_EDIT_DELETE_ALL + 27
MENU_DRAW_TAB_X = MENU_EDIT_DELETE_ALL + 28
MENU_SET_ACTIVE_TAB_COLOR = MENU_EDIT_DELETE_ALL + 29
MENU_SET_TAB_AREA_COLOR = MENU_EDIT_DELETE_ALL + 30
MENU_SELECT_NONACTIVE_TEXT_COLOR = MENU_EDIT_DELETE_ALL + 31
MENU_GRADIENT_BACKGROUND = MENU_EDIT_DELETE_ALL + 32
MENU_COLORFUL_TABS = MENU_EDIT_DELETE_ALL + 33
class FlatNotebookDemo(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.MAXIMIZE |wx.NO_FULL_REPAINT_ON_RESIZE):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self._bShowImages = False
self._bVCStyle = False
self._newPageCounter = 0
self._ImageList = wx.ImageList(16, 16)
self._ImageList.Add(images.get_book_redBitmap())
self._ImageList.Add(images.get_book_greenBitmap())
self._ImageList.Add(images.get_book_blueBitmap())
self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
self.statusbar.SetStatusWidths([-2, -1])
# statusbar fields
statusbar_fields = [("FlatNotebook wxPython Demo, Andrea Gavana @ 02 Oct 2006"),
("Welcome To wxPython!")]
for i in range(len(statusbar_fields)):
self.statusbar.SetStatusText(statusbar_fields[i], i)
self.SetIcon(GetMondrianIcon())
self.CreateMenuBar()
self.CreateRightClickMenu()
self.LayoutItems()
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosing)
def CreateMenuBar(self):
self._menuBar = wx.MenuBar(wx.MB_DOCKABLE)
self._fileMenu = wx.Menu()
item = wx.MenuItem(self._fileMenu, wx.ID_ANY, "&Close\tCtrl-Q", "Close demo window")
self.Bind(wx.EVT_MENU, self.OnQuit, item)
self._fileMenu.AppendItem(item)
self._editMenu = wx.Menu()
item = wx.MenuItem(self._editMenu, MENU_EDIT_ADD_PAGE, "New Page\tCtrl+N", "Add New Page")
self.Bind(wx.EVT_MENU, self.OnAddPage, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_PAGE, "Delete Page\tCtrl+F4", "Delete Page")
self.Bind(wx.EVT_MENU, self.OnDeletePage, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_ALL, "Delete All Pages", "Delete All Pages")
self.Bind(wx.EVT_MENU, self.OnDeleteAll, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_EDIT_SET_SELECTION, "Set Selection", "Set Selection")
self.Bind(wx.EVT_MENU, self.OnSetSelection, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_FWD, "Advance Selection Forward",
"Advance Selection Forward")
self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionFwd, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_BACK, "Advance Selection Backward",
"Advance Selection Backward")
self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionBack, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_SET_ALL_TABS_SHAPE_ANGLE, "Set an inclination of tab header borders",
"Set the shape of tab header")
self.Bind(wx.EVT_MENU, self.OnSetAllPagesShapeAngle, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_SET_PAGE_IMAGE_INDEX, "Set image index of selected page",
"Set image index")
self.Bind(wx.EVT_MENU, self.OnSetPageImageIndex, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_SHOW_IMAGES, "Show Images", "Show Images", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnShowImages, item)
self._editMenu.AppendItem(item)
styleMenu = wx.Menu()
item = wx.MenuItem(styleMenu, MENU_USE_DEFAULT_STYLE, "Use Default Style", "Use VC71 Style", wx.ITEM_RADIO)
self.Bind(wx.EVT_MENU, self.OnDefaultStyle, item)
styleMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_USE_VC71_STYLE, "Use VC71 Style", "Use VC71 Style", wx.ITEM_RADIO)
self.Bind(wx.EVT_MENU, self.OnVC71Style, item)
styleMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_USE_VC8_STYLE, "Use VC8 Style", "Use VC8 Style", wx.ITEM_RADIO)
self.Bind(wx.EVT_MENU, self.OnVC8Style, item)
styleMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_USE_FANCY_STYLE, "Use Fancy Style", "Use Fancy Style", wx.ITEM_RADIO)
self.Bind(wx.EVT_MENU, self.OnFancyStyle, item)
styleMenu.AppendItem(item)
self._editMenu.AppendMenu(wx.ID_ANY, "Tabs Style", styleMenu)
item = wx.MenuItem(styleMenu, MENU_SELECT_GRADIENT_COLOR_FROM, "Select fancy tab style 'from' color",
"Select fancy tab style 'from' color")
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SELECT_GRADIENT_COLOR_TO, "Select fancy tab style 'to' color",
"Select fancy tab style 'to' color")
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SELECT_GRADIENT_COLOR_BORDER, "Select fancy tab style 'border' color",
"Select fancy tab style 'border' color")
self._editMenu.AppendItem(item)
self.Bind(wx.EVT_MENU_RANGE, self.OnSelectColor, id=MENU_SELECT_GRADIENT_COLOR_FROM,
id2=MENU_SELECT_GRADIENT_COLOR_BORDER)
item = wx.MenuItem(self._editMenu, MENU_HIDE_NAV_BUTTONS, "Hide Navigation Buttons",
"Hide Navigation Buttons", wx.ITEM_CHECK)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_HIDE_X, "Hide X Button", "Hide X Button", wx.ITEM_CHECK)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_USE_MOUSE_MIDDLE_BTN, "Use Mouse Middle Button as 'X' button",
"Use Mouse Middle Button as 'X' button", wx.ITEM_CHECK)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_USE_BOTTOM_TABS, "Use Bottoms Tabs", "Use Bottoms Tabs",
wx.ITEM_CHECK)
self._editMenu.AppendItem(item)
self.Bind(wx.EVT_MENU_RANGE, self.OnStyle, id=MENU_HIDE_X, id2=MENU_USE_BOTTOM_TABS)
item = wx.MenuItem(self._editMenu, MENU_ENABLE_TAB, "Enable Tab", "Enable Tab")
self.Bind(wx.EVT_MENU, self.OnEnableTab, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_DISABLE_TAB, "Disable Tab", "Disable Tab")
self.Bind(wx.EVT_MENU, self.OnDisableTab, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_ENABLE_DRAG_N_DROP, "Enable Drag And Drop of Tabs",
"Enable Drag And Drop of Tabs", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnEnableDrag, item)
self._editMenu.AppendItem(item)
item.Check(True)
item = wx.MenuItem(self._editMenu, MENU_DRAW_BORDER, "Draw Border around tab area",
"Draw Border around tab area", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnStyle, item)
self._editMenu.AppendItem(item)
item.Check(True)
item = wx.MenuItem(self._editMenu, MENU_DRAW_TAB_X, "Draw X button On Active Tab",
"Draw X button On Active Tab", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnDrawTabX, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SET_ACTIVE_TAB_COLOR, "Select Active Tab Color",
"Select Active Tab Color")
self.Bind(wx.EVT_MENU, self.OnSelectColor, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SET_TAB_AREA_COLOR, "Select Tab Area Color",
"Select Tab Area Color")
self.Bind(wx.EVT_MENU, self.OnSelectColor, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SET_ACTIVE_TEXT_COLOR, "Select active tab text color",
"Select active tab text color")
self.Bind(wx.EVT_MENU, self.OnSelectColor, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(styleMenu, MENU_SELECT_NONACTIVE_TEXT_COLOR,
"Select NON-active tab text color", "Select NON-active tab text color")
self.Bind(wx.EVT_MENU, self.OnSelectColor, item)
self._editMenu.AppendItem(item)
item = wx.MenuItem(self._editMenu, MENU_DCLICK_CLOSES_TAB, "Mouse double click closes tab",
"Mouse double click closes tab", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnDClickCloseTab, item)
self._editMenu.AppendItem(item)
item.Check(False)
item = wx.MenuItem(self._editMenu, MENU_GRADIENT_BACKGROUND, "Use Gradient Coloring for tab area",
"Use Gradient Coloring for tab area", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnGradientBack, item)
self._editMenu.AppendItem(item)
item.Check(False)
item = wx.MenuItem(self._editMenu, MENU_COLORFUL_TABS, "Colorful tabs", "Colorful tabs", wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.OnColorfulTabs, item)
self._editMenu.AppendItem(item)
item.Check(False)
help_menu = wx.Menu()
item = wx.MenuItem(help_menu, wx.ID_ANY, "About...", "Shows The About Dialog")
self.Bind(wx.EVT_MENU, self.OnAbout, item)
help_menu.AppendItem(item)
self._menuBar.Append(self._fileMenu, "&File")
self._menuBar.Append(self._editMenu, "&Edit")
self._menuBar.Append(help_menu, "&Help")
self.SetMenuBar(self._menuBar)
def CreateRightClickMenu(self):
self._rmenu = wx.Menu()
item = wx.MenuItem(self._rmenu, MENU_EDIT_DELETE_PAGE, "Close Tab\tCtrl+F4", "Close Tab")
self._rmenu.AppendItem(item)
def LayoutItems(self):
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(mainSizer)
bookStyle = fnb.FNB_TABS_BORDER_SIMPLE
self.book = fnb.StyledNotebook(self, wx.ID_ANY, style=bookStyle)
self.secondBook = fnb.StyledNotebook(self, wx.ID_ANY, style=bookStyle)
# Set right click menu to the notebook
self.book.SetRightClickMenu(self._rmenu)
# Set the image list
self.book.SetImageList(self._ImageList)
mainSizer.Add(self.book, 6, wx.EXPAND)
# Add spacer between the books
spacer = wx.Panel(self, -1)
spacer.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
mainSizer.Add(spacer, 0, wx.ALL | wx.EXPAND)
mainSizer.Add(self.secondBook, 2, wx.EXPAND)
# Add some pages to the second notebook
self.Freeze()
text = wx.TextCtrl(self.secondBook, -1, "Second Book Page 1", style=wx.TE_MULTILINE)
self.secondBook.AddPage(text, "Second Book Page 1")
text = wx.TextCtrl(self.secondBook, -1, "Second Book Page 2", style=wx.TE_MULTILINE)
self.secondBook.AddPage(text, "Second Book Page 2")
self.Thaw()
self.Centre()
mainSizer.Layout()
self.SendSizeEvent()
def OnStyle(self, event):
style = self.book.GetWindowStyleFlag()
eventid = event.GetId()
if eventid == MENU_HIDE_NAV_BUTTONS:
if event.IsChecked():
# Hide the navigation buttons
style |= fnb.FNB_NO_NAV_BUTTONS
else:
if style & fnb.FNB_NO_NAV_BUTTONS:
style ^= fnb.FNB_NO_NAV_BUTTONS
self.book.SetWindowStyleFlag(style)
elif eventid == MENU_HIDE_X:
if event.IsChecked():
# Hide the X button
style |= fnb.FNB_NO_X_BUTTON
else:
if style & fnb.FNB_NO_X_BUTTON:
style ^= fnb.FNB_NO_X_BUTTON
self.book.SetWindowStyleFlag(style)
elif eventid == MENU_DRAW_BORDER:
if event.IsChecked():
style |= fnb.FNB_TABS_BORDER_SIMPLE
else:
if style & fnb.FNB_TABS_BORDER_SIMPLE:
style ^= fnb.FNB_TABS_BORDER_SIMPLE
self.book.SetWindowStyleFlag(style)
elif eventid == MENU_USE_MOUSE_MIDDLE_BTN:
if event.IsChecked():
style |= fnb.FNB_MOUSE_MIDDLE_CLOSES_TABS
else:
if style & fnb.FNB_MOUSE_MIDDLE_CLOSES_TABS:
style ^= fnb.FNB_MOUSE_MIDDLE_CLOSES_TABS
self.book.SetWindowStyleFlag(style)
elif eventid == MENU_USE_BOTTOM_TABS:
if event.IsChecked():
style |= fnb.FNB_BOTTOM
else:
if style & fnb.FNB_BOTTOM:
style ^= fnb.FNB_BOTTOM
self.book.SetWindowStyleFlag(style)
self.book.Refresh()
def OnQuit(self, event):
self.Destroy()
def OnDeleteAll(self, event):
self.book.DeleteAllPages()
def OnShowImages(self, event):
self._bShowImages = event.IsChecked()
def OnVC71Style(self, event):
style = self.book.GetWindowStyleFlag()
# remove old tabs style
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
style &= mirror
style |= fnb.FNB_VC71
self.book.SetWindowStyleFlag(style)
def OnVC8Style(self, event):
style = self.book.GetWindowStyleFlag()
# remove old tabs style
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
style &= mirror
# set new style
style |= fnb.FNB_VC8
self.book.SetWindowStyleFlag(style)
def OnDefaultStyle(self, event):
style = self.book.GetWindowStyleFlag()
# remove old tabs style
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
style &= mirror
self.book.SetWindowStyleFlag(style)
def OnFancyStyle(self, event):
style = self.book.GetWindowStyleFlag()
# remove old tabs style
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
style &= mirror
style |= fnb.FNB_FANCY_TABS
self.book.SetWindowStyleFlag(style)
def OnSelectColor(self, event):
eventid = event.GetId()
# Open a color dialog
data = wx.ColourData()
dlg = wx.ColourDialog(self, data)
if dlg.ShowModal() == wx.ID_OK:
if eventid == MENU_SELECT_GRADIENT_COLOR_BORDER:
self.book.SetGradientColorBorder(dlg.GetColourData().GetColour())
elif eventid == MENU_SELECT_GRADIENT_COLOR_FROM:
self.book.SetGradientColorFrom(dlg.GetColourData().GetColour())
elif eventid == MENU_SELECT_GRADIENT_COLOR_TO:
self.book.SetGradientColorTo(dlg.GetColourData().GetColour())
elif eventid == MENU_SET_ACTIVE_TEXT_COLOR:
self.book.SetActiveTabTextColour(dlg.GetColourData().GetColour())
elif eventid == MENU_SELECT_NONACTIVE_TEXT_COLOR:
self.book.SetNonActiveTabTextColour(dlg.GetColourData().GetColour())
elif eventid == MENU_SET_ACTIVE_TAB_COLOR:
self.book.SetActiveTabColour(dlg.GetColourData().GetColour())
elif eventid == MENU_SET_TAB_AREA_COLOR:
self.book.SetTabAreaColour(dlg.GetColourData().GetColour())
self.book.Refresh()
def OnAddPage(self, event):
caption = "New Page Added #" + str(self._newPageCounter)
self.Freeze()
image = -1
if self._bShowImages:
image = random.randint(0, self._ImageList.GetImageCount()-1)
self.book.AddPage(self.CreatePage(caption), caption, True, image)
self.book.SetSelection(self.book.GetPageCount()-1)
self.Thaw()
self._newPageCounter = self._newPageCounter + 1
def CreatePage(self, caption):
return wx.TextCtrl(self.book, -1, caption, wx.DefaultPosition, self.book.GetPageBestSize(),
wx.TE_MULTILINE)
def OnDeletePage(self, event):
self.book.DeletePage(self.book.GetSelection())
def OnSetSelection(self, event):
dlg = wx.TextEntryDialog(self, "Enter Tab Number to select:", "Set Selection")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
self.book.SetSelection(int(val))
def OnEnableTab(self, event):
dlg = wx.TextEntryDialog(self, "Enter Tab Number to enable:", "Enable Tab")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
self.book.Enable(int(val))
def OnDisableTab(self, event):
dlg = wx.TextEntryDialog(self, "Enter Tab Number to disable:", "Disable Tab")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
self.book.Enable(int(val), False)
def OnEnableDrag(self, event):
style = self.book.GetWindowStyleFlag()
if event.IsChecked():
if style & fnb.FNB_NODRAG:
style ^= fnb.FNB_NODRAG
else:
style |= fnb.FNB_NODRAG
self.book.SetWindowStyleFlag(style)
def OnSetAllPagesShapeAngle(self, event):
dlg = wx.TextEntryDialog(self, "Enter an inclination of header borders (0-45):", "Set Angle")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
self.book.SetAllPagesShapeAngle(int(val))
def OnSetPageImageIndex(self, event):
dlg = wx.TextEntryDialog(self, "Enter an image index (0-%i):"%(self.book.GetImageList().GetImageCount()-1), "Set Image Index")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
self.book.SetPageImageIndex(self.book.GetSelection(), int(val))
def OnAdvanceSelectionFwd(self, event):
self.book.AdvanceSelection(True)
def OnAdvanceSelectionBack(self, event):
self.book.AdvanceSelection(False)
def OnPageChanging(self, event):
print "Page Changing From", event.GetOldSelection(), "To", event.GetSelection()
event.Skip()
def OnPageChanged(self, event):
print "Page Changed To", event.GetSelection()
event.Skip()
def OnPageClosing(self, event):
print "Page Closing, Selection:", event.GetSelection()
event.Skip()
def OnDrawTabX(self, event):
style = self.book.GetWindowStyleFlag()
if event.IsChecked():
style |= fnb.FNB_X_ON_TAB
else:
if style & fnb.FNB_X_ON_TAB:
style ^= fnb.FNB_X_ON_TAB
self.book.SetWindowStyleFlag(style)
def OnDClickCloseTab(self, event):
style = self.book.GetWindowStyleFlag()
if event.IsChecked():
style |= fnb.FNB_DCLICK_CLOSES_TABS
else:
style &= ~(fnb.FNB_DCLICK_CLOSES_TABS)
self.book.SetWindowStyleFlag(style)
def OnGradientBack(self, event):
style = self.book.GetWindowStyleFlag()
if event.IsChecked():
style |= fnb.FNB_BACKGROUND_GRADIENT
else:
style &= ~(fnb.FNB_BACKGROUND_GRADIENT)
self.book.SetWindowStyleFlag(style)
self.book.Refresh()
def OnColorfulTabs(self, event):
style = self.book.GetWindowStyleFlag()
if event.IsChecked():
style |= fnb.FNB_COLORFUL_TABS
else:
style &= ~(fnb.FNB_COLORFUL_TABS)
self.book.SetWindowStyleFlag(style)
self.book.Refresh()
def OnAbout(self, event):
msg = "This Is The About Dialog Of The FlatNotebook Demo.\n\n" + \
"Author: Andrea Gavana @ 02 Oct 2006\n\n" + \
"Please Report Any Bug/Requests Of Improvements\n" + \
"To Me At The Following Adresses:\n\n" + \
"andrea.gavana@gmail.com\n" + "gavana@kpo.kz\n\n" + \
"Based On Eran C++ Implementation (wxWidgets Forum).\n\n" + \
"Welcome To wxPython " + wx.VERSION_STRING + "!!"
dlg = wx.MessageDialog(self, msg, "FlatNotebook wxPython Demo",
wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, " Test ButtonPanel ", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
self.win = FlatNotebookDemo(self, title="FlatNotebook Demo")
self.win.Show(True)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """<html><body>
<h2><center>Say something nice here</center></h2>
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -64,6 +64,7 @@ _treeList = [
'DelayedResult',
'ExpandoTextCtrl',
'ButtonPanel',
'FlatNotebook',
]),
# managed windows == things with a (optional) caption you can close
@@ -151,6 +152,7 @@ _treeList = [
'ColourSelect',
'ComboTreeBox',
'Editor',
'FlatNotebook',
'GenericButtons',
'GenericDirCtrl',
'LEDNumberCtrl',

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

View File

@@ -96,6 +96,10 @@ command_lines = [
"-a -u -n _bp_btn3 bmp_source/bp_btn3.png images.py",
"-a -u -n _bp_btn4 bmp_source/bp_btn4.png images.py",
"-a -u -n _book_red bmp_source/book_red.png images.py",
"-a -u -n _book_green bmp_source/book_green.png images.py",
"-a -u -n _book_blue bmp_source/book_blue.png images.py",
" -u -c bmp_source/001.png throbImages.py",
"-a -u -c bmp_source/002.png throbImages.py",
"-a -u -c bmp_source/003.png throbImages.py",

View File

@@ -13172,3 +13172,120 @@ def get_bp_btn4Image():
stream = cStringIO.StringIO(get_bp_btn4Data())
return ImageFromStream(stream)
#----------------------------------------------------------------------
def get_book_redData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x02\x93IDAT8\x8d\x85\x93IL\x13\x01\x14\x86\xbf\x99i;]hiA\x10\xa4\xac\
\x01!F\xa0\x88V0\xe8\x81\x8b&x0&xr\xbb\xe8\xd9\x03^8\x18\xaf&\xc6\xab\x07o\\\
\x8d1j\x0c\xd1\xb8DM\x10\x8d\xa0\x18\x16\x03H*K(e\x11\xbaMg\xa63\xe3\xc1bPP\
\xff\xe4%\xef\xf0\xde\x97\xbc\xf7\xbf\'\xf0o\t[r\xeb\x7f\x05\xc2u\x10\xba\
\x83\xd4\x9b\x1aa\xc1\xcd!\xf7\xae@kZQ\xb5Kc\xe9\xf3o!\n\xa8\xdb\x00J\x88\
\xa3\x96C\xec\x12\xf3\xfd\x07E\xa7\xbb\xd5t\xb9\xfdr\x9e\x0bL\x13\x1c2d\x15\
\xfa\x9fM<95k^\xd5`\xf2O\x88t\xad%8h+\xad<\xe1h9P#\x19\xa63[V\x8b^Z\x8b\xd1t\
\x0c#\xd4\x89M\xcbP\'&k\xcb\x97\xd6}\x0f\x14F\x808`\xfe\x02\xf4\x04\xed=r\
\xbe7/\xab\x0bHj\x82D\xb8\x0b\xb1p7\xa2+\x0f\x9b\xa1#\xcaNX\x9c\xa2)`o\xb4\
\xcf\xc6\xf5\x97\x06\xe3@j\x13"]t\xa8\x1dE\xf5\xe5\r\x89\xaf\xb38KK\xb0E#H\
\xd1o\xc8\xc3\xcf\x11\x07\xfba\xfc\x03\xe8*\x82\xc3&\x84\xf2\xed\xe1\xb5\xf9\
\xf4\xf2\x90\xc54\x90\x06,\xa9M\xb7\x96\xf7\xc9\xda9W\xb0XH\xac\xa5qgV\x91V\
\x97@\xd7@\x94~\xee\xd94\xc1\xd0\x91=\x82xX\xca\xb6\x8f-\x1b3\xd3\x10\x01\
\x14\xf1l\x9cw\xe3S+\xf7\x05K%\xb3\xf2\x1d<\x01\xb0L0\x0c0t\xc8*\x90Z\'9\xb9\
\xc4\xd8@\x8c\x91\x92f\xb7!\x8a\xfb\x81j\xc0a\x03\x94\xc7\xcb\xdc\xa8\x18\
\x9d\xef*n\xaev\xaeGb\xf8\xbd\x1a,\xae\x10\x8d\x1a\x8c\x17\x941S\xd9\x8e~\
\xa1\x03g\xb8\x9d`e\x85\xf2to\xb5\x0cx\x00\xd1\x06\x98\xbd*\xa3\x8d3\xa9\xbe\
\x93\xe5\xb1\xcb\xaf")V\x82\r\xac\xb7\x9dAk\t\xe3\xf3\xfb\xf1y\xbd\x14x<\xb8\
\xbd~\x8a%\xcb\xd5S\x8c\xe3f\x0c\x050m972w7\xb8U\xf6"\xd6}\xe7\xf8\xe9@y\xeb\
\x11\xea\xaa*)\xf4\xe5\x13\x10\xb2\xd4.|\xa4h\xe2=\xfe\xa1\xd7\xca\xd0\xec\
\xc2\'\xd1\x00\xc0\x0f\xc8\x9b\x00\xab\x0f"\x9d)nWY\x99\xdeP|\x8a\xb6\x817\
\x14\x8c\x0e[\xc9\xa9\xb9\xc9{k|y\xa4\xb3:d`h\x16\x1b\xc0\\\xceJ\xeb\xb7S\
\x0e\xc1\x9e+.\x1ej\xa0\xf6)L\x7f\x065\x0e\x19 \x06\xcc\xe7b\x11\xd8\x00\x12\
@r+\x00\xc0\x0e\xd4\x00\x1d\x80{K\xd3*\x90\xccy\x9f\x01\x0cr\xcf\xf5\'\x00@\
\x06\x02\x80\x98kP\x00ms\xd4\x1d\xeaw\x94\xf0\x17\xf86\xfd\x00\x8a\x84\x08\
\xee\xfb\x9c!f\x00\x00\x00\x00IEND\xaeB`\x82'
def get_book_redBitmap():
return BitmapFromImage(get_book_redImage())
def get_book_redImage():
stream = cStringIO.StringIO(get_book_redData())
return ImageFromStream(stream)
#----------------------------------------------------------------------
def get_book_greenData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x02\x86IDAT8\x8d\x8d\x93KO\x13\x01\x14\x85\xbf\x99\xd2\x16;}\xd2\xa0\
\x04\xca\xa3\x14\x14\x8d\x90\xa0<\x95\x88\xba\xc0\x84\xc4\xc4\x10W\xb8\xd0\
\x95\xbf@]\xf8\x0b\xdc\xb81\xae\xdc\x1b\xf6\x1a\x90\x95\x90\x08\xf8\x08\x04$\
\x014\x95RD\x9em\xa1\xf41\xd3i;3nF\x82\x10\x1fgu\x93{\xef\x97\xdc\x9cs\x05\
\xfe.\xe1Pm\xfck@`\x10\x91f\x9a\xc8\xd0!:h?\xe5w^\xcc\xc8\x059\xfdL\xbdK\x94\
m@=\x0e\x18\xe2:\x1a\xfd\x95\x92\xa7\xcd\'Z[\xfd6\xbb\xdb\xeb\xb4\xa1\xcay,y\
\'\x05)\xc7\xf8\xf0\xea\x9b\xc2s\x1e\xa1\x12>\n\xb1\xf4\xde\xaf\x9f\x0b\x9d\
\xa8\xbd\xd6W_S\xa7\xc5\xad\xf6ZK\x13U\xfa9:+\xfa\xb8T\xd5Gb?\x0e\x81T\xe3\
\xa6-\xebb\x96\xcf@\x1a\xd0\x0f\x00\xe57\x1d\x8f\xeb\x02n{"!\xa0\xe4S\xdc\
\xa8\xbb\x85\xdfS\x8edw\xa2\x14\xb3H6\x89Hf\x11)X\xda\x12C.\xb0\xc0\x12\x90\
\xfd\x05\xb1d[\xf2W\xfb\xbb\x1aB\x13\xe1\x1fTT8X\xddZ#*\x87\x19\xdf\x1aa<6\
\xcalr\x16U3\x10\xad\xa2`\xad\xb1t\xa4\xf7\xd5\x18+|\x03d\xc0\xb0\xa8\x15ZB\
\xf4\x19\x83\xcd\x8d\xe5\xc2r4GZ\xda$^\x88\xa1\x1a\x1a\x026tD\x8a\xba\x81Z,"\
:\x0c\xb1X]\xec\xce\xaf\x19\x11\xb6\x89\x02\x8a\xc8\x10\xef\xa6&\xd7G\xec\
\x86\x81\xaaeq\ne\x14u\x01\r\x03U\xd0PD\x95=}\x9f\xc8N\x92\x95\xf9\x14g\xb3\
\xad\x0e\x04\xce\x03A\xc0V\x02\xc8\xea\\\xf1\xc9X0\xda\xd7\xdb\x1b\xb4\x8e\
\xcd\xed`9\xa9\xb2\x11\xdbco\x07\x02\xe9J\xda\xf4+\\\xf6\xf7\xd0}\xa6\x8b\
\xda@\xb5\x1cz\x18\xb2\x03\x12 \x96\x00:o\x99\xf9\x1a\x8c\xbf\x0c5\xb8\xefm~\
\xd8\xa5\xdev\x9a;\xde\x1e:\xca\xda\xf1\xd5yqy\\8\x9d\x12^\x8f\x0f\xd1\xa7;\
\xe8\xc4\xc6G\x14@/1\xdd\xc8iK<}=\x1a\x19\x18X\xbd\xed\xeen\xe9"TS\x8f\xcb\
\xe5\xa6`Q\xf9\x94\x9b`z\xeb=\x93\xf1\te#\x9a\x9c7\x03\xe8\x03\xec\xbf\x00\
\x06S\x84i\xe4E^\xca=X\xcc/0\xb2<\xcc\x8c<\xad\xa7v\xd3a"|a\x99]\xb6)\xa0\
\x91\x06\xbe\x9bV\x1a\xbfG9D\r\x17x\x85B\x9aE"l\xa0\x92C\x01b\xc0:\xb0\x06l\
\x01I3P\x99\xc3\x00\x00+\xd0\x00\xf4\x00\xa5\xe6\xc2:\x90\x002\xa6\xf79@\xc3\
|\xae\xa3\x00\xccE\x9f\xd9\x93\x01\x05\xc8\x1f\x9c\xfa\x9f\x12\xfe\x00?\xa6\
\x9f\x16\xa0\x0c\xe8\xa4\xc9\xa8\x14\x00\x00\x00\x00IEND\xaeB`\x82'
def get_book_greenBitmap():
return BitmapFromImage(get_book_greenImage())
def get_book_greenImage():
stream = cStringIO.StringIO(get_book_greenData())
return ImageFromStream(stream)
#----------------------------------------------------------------------
def get_book_blueData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x02\x82IDAT8\x8d\x8d\x93KHTa\x14\xc7\x7f\xf7\xce\x1d\xc7y\xdc\x19G\xd4L\
\x1bS\xc7Wi\x90\xe4\xa3\x87A\xb6\x88H\x08\xb2U\x11\xd4\xae\x16\xed\x8a\x16-j\
\xdb\xa6u\xd0\xaeE\x9b\xa2\x16\x82\xf6 #\x12E"\xf1\x85`\xf8`\xd4&\x1cu\xd4q\
\xee\xdc\x87w\xe6\xde\x16\x8dbJ\x8f\xff\xea\x1c\xce9?\xce\xf9\xbes\x04\xfe.a\
\x87m\xff+A\x80\x17"W\x1cu$\x85\x16\xdc\xdefd\xff1\xb4\r\x95\x9e\xfb\xd7I\
\x0c\xc5\x00c/\xe0\xf6\xc2Y\x04\xf3\x02rn\x13.\xb5\x11\xdc~D7\xa8\x1a":\x96-\
\xc1\xf8\xc77t\xdf\xba\x07\xc6\xd4n\x88#t\xe9\xceH\xb1l\xb7\'C\x07\xca=K+\
\xae#>\x83\x16\x7f\x8a\x8eCN:\xeb=,&\x0cb\x14U\xe3\x0e\xcb\xcc\xbd\x1d\x05\
\x92\x80\xb5\x05\x10\x17\xd65\xc1\x99\x9fO\xd1J\x14=#\xd0^\xef\xa5\xae\\&\
\xcf-\xb1\xa6\xc1\xd12\x1fH\x12T\x9d\xbaF\xe3\x83\x9b@\t mw@\xd1\xf93fkC\xd8\
53O\xca\x1b`1\xa60\x11\xcb\xf0z,E\xdfH\x82\xd1oq\xd0S`g\x04\xe4P\x0b\xa6\xb4\
\xcc\xea\xf04\xa0\x02\xb6\x03gm\\\xf7\x85\xaf\xe6\xd6V\n\xf2\xf7\x19"\x8a\
\xc4Z\xc2\x00\xc3\x00{\x132&\xa4\xd3\xbf|\xcb\x12qW\x9c@K\xcc\xa2LG\x00Md\
\xfca\x1f\x83\x9fz\x96,\x11]t\x12\x946\xc14\xc0L\x83a\x82\x91\x01\xc5\x84%\
\x15\xa2q\x1aK4\x8f d\x1a\x80\n G\x02T\xa6\x06\x1e\xd1W}.\xd1\xde\xea\x0c\
\xf6\x0f\x80\xe9\x865\r\x94$\xfb\xfck\x1c/Mq\xb2\xddAk\x8d\x87P\xa8X\r?{\xef\
\x02\xbc\x80(\x01\x16\xd1\'C\x8c\x1f~\x9e\x0e\xd7\xde\xd0f\x87i)\xd2ik\x80\
\xa6\x83"\x81\x80\x0f9\x10\xc0\xe7\xf5\x11\xcc\x93Q=\xfb=\x94^\xce!\xfaJ\x03\
\xac\xad\xd7\xd4\xf9\xf1\xf91\xdd\x85\x9d\x1d\xc5]\xfe\xe6\xbaz*\xabk\xf0\
\xcb^t\xdb\xc3\x87\x88\x9b\xfe\x88\x83\xde\xc9\x94\xc6\xdc\xbb1,\x04 \x08\
\xb8\xb6\x006\x8b/\xa7(8\xfdT\x15\n\xeeN,\xf9\xe8\x9e\x11\xf8\x1a\xb1\xacdly\
\x8a\xe4\x97I6\x06WIM\x9b\xd8f\x12\x98\x07R\x80\xfd\xfb*\x07\x9b\xcb(\xbc\
\xd8\x85\xa9$\x89\xf7\xce\xa2N\x1a\xa4\x15\rX\x06\xa2\xc0\x02\xb0\x08\xacg\
\x17J\xd9\t\x00p\x02U@\x1b\x90\x9b-\x88\x02q@\xc9\xfe\xbd\x0ed\xc8\x1e\xd7n\
\x00\xd9\xc2`6\xa6\x02\x1a\xb0\xb9=\xea\x7fJ\xf8\x03|\x8f~\x02x\xb0\xfe\xe3\
\xe93\x0e\xf5\x00\x00\x00\x00IEND\xaeB`\x82'
def get_book_blueBitmap():
return BitmapFromImage(get_book_blueImage())
def get_book_blueImage():
stream = cStringIO.StringIO(get_book_blueData())
return ImageFromStream(stream)

View File

@@ -261,6 +261,9 @@ resampling methods for upsampling and downsampling respectively.
Added the wx.lib.buttonpanel module, which is a tweaked version of
Andrea Gavana's FancyButtonPanel module.
Added the wx.lib.flatnotebook module, from Andrea Gavana.

File diff suppressed because it is too large Load Diff