3 import wx
.lib
.flatnotebook
as fnb
7 #----------------------------------------------------------------------
10 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
11 \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
12 ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
13 o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
14 \xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
15 \x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
16 \x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82'
19 def GetMondrianBitmap():
20 return wx
.BitmapFromImage(GetMondrianImage())
23 def GetMondrianImage():
25 stream
= cStringIO
.StringIO(GetMondrianData())
26 return wx
.ImageFromStream(stream
)
29 def GetMondrianIcon():
31 icon
.CopyFromBitmap(GetMondrianBitmap())
33 #----------------------------------------------------------------------
36 MENU_EDIT_DELETE_ALL
= wx
.ID_HIGHEST
+ 1000
37 MENU_EDIT_ADD_PAGE
= MENU_EDIT_DELETE_ALL
+ 1
38 MENU_EDIT_DELETE_PAGE
= MENU_EDIT_DELETE_ALL
+ 2
39 MENU_EDIT_SET_SELECTION
= MENU_EDIT_DELETE_ALL
+ 3
40 MENU_EDIT_ADVANCE_SELECTION_FWD
= MENU_EDIT_DELETE_ALL
+ 4
41 MENU_EDIT_ADVANCE_SELECTION_BACK
= MENU_EDIT_DELETE_ALL
+ 5
42 MENU_SET_ALL_TABS_SHAPE_ANGLE
= MENU_EDIT_DELETE_ALL
+ 6
43 MENU_SHOW_IMAGES
= MENU_EDIT_DELETE_ALL
+ 7
44 MENU_USE_VC71_STYLE
= MENU_EDIT_DELETE_ALL
+ 8
45 MENU_USE_DEFAULT_STYLE
= MENU_EDIT_DELETE_ALL
+ 9
46 MENU_USE_FANCY_STYLE
= MENU_EDIT_DELETE_ALL
+ 10
47 MENU_SELECT_GRADIENT_COLOR_FROM
= MENU_EDIT_DELETE_ALL
+ 11
48 MENU_SELECT_GRADIENT_COLOR_TO
= MENU_EDIT_DELETE_ALL
+ 12
49 MENU_SELECT_GRADIENT_COLOR_BORDER
= MENU_EDIT_DELETE_ALL
+ 13
50 MENU_SET_PAGE_IMAGE_INDEX
= MENU_EDIT_DELETE_ALL
+ 14
51 MENU_HIDE_X
= MENU_EDIT_DELETE_ALL
+ 15
52 MENU_HIDE_NAV_BUTTONS
= MENU_EDIT_DELETE_ALL
+ 16
53 MENU_USE_MOUSE_MIDDLE_BTN
= MENU_EDIT_DELETE_ALL
+ 17
54 MENU_DRAW_BORDER
= MENU_EDIT_DELETE_ALL
+ 18
55 MENU_USE_BOTTOM_TABS
= MENU_EDIT_DELETE_ALL
+ 19
56 MENU_ENABLE_TAB
= MENU_EDIT_DELETE_ALL
+ 20
57 MENU_DISABLE_TAB
= MENU_EDIT_DELETE_ALL
+ 21
58 MENU_ENABLE_DRAG_N_DROP
= MENU_EDIT_DELETE_ALL
+ 22
59 MENU_DCLICK_CLOSES_TAB
= MENU_EDIT_DELETE_ALL
+ 23
60 MENU_USE_VC8_STYLE
= MENU_EDIT_DELETE_ALL
+ 24
62 MENU_SET_ACTIVE_TEXT_COLOR
= MENU_EDIT_DELETE_ALL
+ 27
63 MENU_DRAW_TAB_X
= MENU_EDIT_DELETE_ALL
+ 28
64 MENU_SET_ACTIVE_TAB_COLOR
= MENU_EDIT_DELETE_ALL
+ 29
65 MENU_SET_TAB_AREA_COLOR
= MENU_EDIT_DELETE_ALL
+ 30
66 MENU_SELECT_NONACTIVE_TEXT_COLOR
= MENU_EDIT_DELETE_ALL
+ 31
67 MENU_GRADIENT_BACKGROUND
= MENU_EDIT_DELETE_ALL
+ 32
68 MENU_COLORFUL_TABS
= MENU_EDIT_DELETE_ALL
+ 33
71 class FlatNotebookDemo(wx
.Frame
):
73 def __init__(self
, parent
, id=wx
.ID_ANY
, title
="", pos
=wx
.DefaultPosition
, size
=(800, 600),
74 style
=wx
.DEFAULT_FRAME_STYLE | wx
.MAXIMIZE |wx
.NO_FULL_REPAINT_ON_RESIZE
):
76 wx
.Frame
.__init
__(self
, parent
, id, title
, pos
, size
, style
)
78 self
._bShowImages
= False
79 self
._bVCStyle
= False
80 self
._newPageCounter
= 0
82 self
._ImageList
= wx
.ImageList(16, 16)
83 self
._ImageList
.Add(images
.get_book_redBitmap())
84 self
._ImageList
.Add(images
.get_book_greenBitmap())
85 self
._ImageList
.Add(images
.get_book_blueBitmap())
87 self
.statusbar
= self
.CreateStatusBar(2, wx
.ST_SIZEGRIP
)
88 self
.statusbar
.SetStatusWidths([-2, -1])
90 statusbar_fields
= [("FlatNotebook wxPython Demo, Andrea Gavana @ 02 Oct 2006"),
91 ("Welcome To wxPython!")]
93 for i
in range(len(statusbar_fields
)):
94 self
.statusbar
.SetStatusText(statusbar_fields
[i
], i
)
96 self
.SetIcon(GetMondrianIcon())
98 self
.CreateRightClickMenu()
101 self
.Bind(fnb
.EVT_FLATNOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
102 self
.Bind(fnb
.EVT_FLATNOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
103 self
.Bind(fnb
.EVT_FLATNOTEBOOK_PAGE_CLOSING
, self
.OnPageClosing
)
107 def CreateMenuBar(self
):
109 self
._menuBar
= wx
.MenuBar(wx
.MB_DOCKABLE
)
110 self
._fileMenu
= wx
.Menu()
111 item
= wx
.MenuItem(self
._fileMenu
, wx
.ID_ANY
, "&Close\tCtrl-Q", "Close demo window")
112 self
.Bind(wx
.EVT_MENU
, self
.OnQuit
, item
)
113 self
._fileMenu
.AppendItem(item
)
115 self
._editMenu
= wx
.Menu()
116 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_ADD_PAGE
, "New Page\tCtrl+N", "Add New Page")
117 self
.Bind(wx
.EVT_MENU
, self
.OnAddPage
, item
)
118 self
._editMenu
.AppendItem(item
)
120 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_DELETE_PAGE
, "Delete Page\tCtrl+F4", "Delete Page")
121 self
.Bind(wx
.EVT_MENU
, self
.OnDeletePage
, item
)
122 self
._editMenu
.AppendItem(item
)
124 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_DELETE_ALL
, "Delete All Pages", "Delete All Pages")
125 self
.Bind(wx
.EVT_MENU
, self
.OnDeleteAll
, item
)
126 self
._editMenu
.AppendItem(item
)
128 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_SET_SELECTION
, "Set Selection", "Set Selection")
129 self
.Bind(wx
.EVT_MENU
, self
.OnSetSelection
, item
)
130 self
._editMenu
.AppendItem(item
)
132 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_ADVANCE_SELECTION_FWD
, "Advance Selection Forward",
133 "Advance Selection Forward")
134 self
.Bind(wx
.EVT_MENU
, self
.OnAdvanceSelectionFwd
, item
)
135 self
._editMenu
.AppendItem(item
)
137 item
= wx
.MenuItem(self
._editMenu
, MENU_EDIT_ADVANCE_SELECTION_BACK
, "Advance Selection Backward",
138 "Advance Selection Backward")
139 self
.Bind(wx
.EVT_MENU
, self
.OnAdvanceSelectionBack
, item
)
140 self
._editMenu
.AppendItem(item
)
142 item
= wx
.MenuItem(self
._editMenu
, MENU_SET_ALL_TABS_SHAPE_ANGLE
, "Set an inclination of tab header borders",
143 "Set the shape of tab header")
144 self
.Bind(wx
.EVT_MENU
, self
.OnSetAllPagesShapeAngle
, item
)
145 self
._editMenu
.AppendItem(item
)
147 item
= wx
.MenuItem(self
._editMenu
, MENU_SET_PAGE_IMAGE_INDEX
, "Set image index of selected page",
149 self
.Bind(wx
.EVT_MENU
, self
.OnSetPageImageIndex
, item
)
150 self
._editMenu
.AppendItem(item
)
152 item
= wx
.MenuItem(self
._editMenu
, MENU_SHOW_IMAGES
, "Show Images", "Show Images", wx
.ITEM_CHECK
)
153 self
.Bind(wx
.EVT_MENU
, self
.OnShowImages
, item
)
154 self
._editMenu
.AppendItem(item
)
156 styleMenu
= wx
.Menu()
157 item
= wx
.MenuItem(styleMenu
, MENU_USE_DEFAULT_STYLE
, "Use Default Style", "Use VC71 Style", wx
.ITEM_RADIO
)
158 self
.Bind(wx
.EVT_MENU
, self
.OnDefaultStyle
, item
)
159 styleMenu
.AppendItem(item
)
161 item
= wx
.MenuItem(styleMenu
, MENU_USE_VC71_STYLE
, "Use VC71 Style", "Use VC71 Style", wx
.ITEM_RADIO
)
162 self
.Bind(wx
.EVT_MENU
, self
.OnVC71Style
, item
)
163 styleMenu
.AppendItem(item
)
165 item
= wx
.MenuItem(styleMenu
, MENU_USE_VC8_STYLE
, "Use VC8 Style", "Use VC8 Style", wx
.ITEM_RADIO
)
166 self
.Bind(wx
.EVT_MENU
, self
.OnVC8Style
, item
)
167 styleMenu
.AppendItem(item
)
169 item
= wx
.MenuItem(styleMenu
, MENU_USE_FANCY_STYLE
, "Use Fancy Style", "Use Fancy Style", wx
.ITEM_RADIO
)
170 self
.Bind(wx
.EVT_MENU
, self
.OnFancyStyle
, item
)
171 styleMenu
.AppendItem(item
)
173 self
._editMenu
.AppendMenu(wx
.ID_ANY
, "Tabs Style", styleMenu
)
175 item
= wx
.MenuItem(styleMenu
, MENU_SELECT_GRADIENT_COLOR_FROM
, "Select fancy tab style 'from' color",
176 "Select fancy tab style 'from' color")
177 self
._editMenu
.AppendItem(item
)
179 item
= wx
.MenuItem(styleMenu
, MENU_SELECT_GRADIENT_COLOR_TO
, "Select fancy tab style 'to' color",
180 "Select fancy tab style 'to' color")
181 self
._editMenu
.AppendItem(item
)
183 item
= wx
.MenuItem(styleMenu
, MENU_SELECT_GRADIENT_COLOR_BORDER
, "Select fancy tab style 'border' color",
184 "Select fancy tab style 'border' color")
185 self
._editMenu
.AppendItem(item
)
187 self
.Bind(wx
.EVT_MENU_RANGE
, self
.OnSelectColor
, id=MENU_SELECT_GRADIENT_COLOR_FROM
,
188 id2
=MENU_SELECT_GRADIENT_COLOR_BORDER
)
190 item
= wx
.MenuItem(self
._editMenu
, MENU_HIDE_NAV_BUTTONS
, "Hide Navigation Buttons",
191 "Hide Navigation Buttons", wx
.ITEM_CHECK
)
192 self
._editMenu
.AppendItem(item
)
194 item
= wx
.MenuItem(self
._editMenu
, MENU_HIDE_X
, "Hide X Button", "Hide X Button", wx
.ITEM_CHECK
)
195 self
._editMenu
.AppendItem(item
)
197 item
= wx
.MenuItem(self
._editMenu
, MENU_USE_MOUSE_MIDDLE_BTN
, "Use Mouse Middle Button as 'X' button",
198 "Use Mouse Middle Button as 'X' button", wx
.ITEM_CHECK
)
199 self
._editMenu
.AppendItem(item
)
201 item
= wx
.MenuItem(self
._editMenu
, MENU_USE_BOTTOM_TABS
, "Use Bottoms Tabs", "Use Bottoms Tabs",
203 self
._editMenu
.AppendItem(item
)
205 self
.Bind(wx
.EVT_MENU_RANGE
, self
.OnStyle
, id=MENU_HIDE_X
, id2
=MENU_USE_BOTTOM_TABS
)
207 item
= wx
.MenuItem(self
._editMenu
, MENU_ENABLE_TAB
, "Enable Tab", "Enable Tab")
208 self
.Bind(wx
.EVT_MENU
, self
.OnEnableTab
, item
)
209 self
._editMenu
.AppendItem(item
)
211 item
= wx
.MenuItem(self
._editMenu
, MENU_DISABLE_TAB
, "Disable Tab", "Disable Tab")
212 self
.Bind(wx
.EVT_MENU
, self
.OnDisableTab
, item
)
213 self
._editMenu
.AppendItem(item
)
215 item
= wx
.MenuItem(self
._editMenu
, MENU_ENABLE_DRAG_N_DROP
, "Enable Drag And Drop of Tabs",
216 "Enable Drag And Drop of Tabs", wx
.ITEM_CHECK
)
217 self
.Bind(wx
.EVT_MENU
, self
.OnEnableDrag
, item
)
218 self
._editMenu
.AppendItem(item
)
221 item
= wx
.MenuItem(self
._editMenu
, MENU_DRAW_BORDER
, "Draw Border around tab area",
222 "Draw Border around tab area", wx
.ITEM_CHECK
)
223 self
.Bind(wx
.EVT_MENU
, self
.OnStyle
, item
)
224 self
._editMenu
.AppendItem(item
)
227 item
= wx
.MenuItem(self
._editMenu
, MENU_DRAW_TAB_X
, "Draw X button On Active Tab",
228 "Draw X button On Active Tab", wx
.ITEM_CHECK
)
229 self
.Bind(wx
.EVT_MENU
, self
.OnDrawTabX
, item
)
230 self
._editMenu
.AppendItem(item
)
232 item
= wx
.MenuItem(styleMenu
, MENU_SET_ACTIVE_TAB_COLOR
, "Select Active Tab Color",
233 "Select Active Tab Color")
234 self
.Bind(wx
.EVT_MENU
, self
.OnSelectColor
, item
)
235 self
._editMenu
.AppendItem(item
)
237 item
= wx
.MenuItem(styleMenu
, MENU_SET_TAB_AREA_COLOR
, "Select Tab Area Color",
238 "Select Tab Area Color")
239 self
.Bind(wx
.EVT_MENU
, self
.OnSelectColor
, item
)
240 self
._editMenu
.AppendItem(item
)
242 item
= wx
.MenuItem(styleMenu
, MENU_SET_ACTIVE_TEXT_COLOR
, "Select active tab text color",
243 "Select active tab text color")
244 self
.Bind(wx
.EVT_MENU
, self
.OnSelectColor
, item
)
245 self
._editMenu
.AppendItem(item
)
247 item
= wx
.MenuItem(styleMenu
, MENU_SELECT_NONACTIVE_TEXT_COLOR
,
248 "Select NON-active tab text color", "Select NON-active tab text color")
249 self
.Bind(wx
.EVT_MENU
, self
.OnSelectColor
, item
)
250 self
._editMenu
.AppendItem(item
)
252 item
= wx
.MenuItem(self
._editMenu
, MENU_DCLICK_CLOSES_TAB
, "Mouse double click closes tab",
253 "Mouse double click closes tab", wx
.ITEM_CHECK
)
254 self
.Bind(wx
.EVT_MENU
, self
.OnDClickCloseTab
, item
)
255 self
._editMenu
.AppendItem(item
)
258 item
= wx
.MenuItem(self
._editMenu
, MENU_GRADIENT_BACKGROUND
, "Use Gradient Coloring for tab area",
259 "Use Gradient Coloring for tab area", wx
.ITEM_CHECK
)
260 self
.Bind(wx
.EVT_MENU
, self
.OnGradientBack
, item
)
261 self
._editMenu
.AppendItem(item
)
264 item
= wx
.MenuItem(self
._editMenu
, MENU_COLORFUL_TABS
, "Colorful tabs", "Colorful tabs", wx
.ITEM_CHECK
)
265 self
.Bind(wx
.EVT_MENU
, self
.OnColorfulTabs
, item
)
266 self
._editMenu
.AppendItem(item
)
269 help_menu
= wx
.Menu()
270 item
= wx
.MenuItem(help_menu
, wx
.ID_ANY
, "About...", "Shows The About Dialog")
271 self
.Bind(wx
.EVT_MENU
, self
.OnAbout
, item
)
272 help_menu
.AppendItem(item
)
274 self
._menuBar
.Append(self
._fileMenu
, "&File")
275 self
._menuBar
.Append(self
._editMenu
, "&Edit")
276 self
._menuBar
.Append(help_menu
, "&Help")
278 self
.SetMenuBar(self
._menuBar
)
281 def CreateRightClickMenu(self
):
283 self
._rmenu
= wx
.Menu()
284 item
= wx
.MenuItem(self
._rmenu
, MENU_EDIT_DELETE_PAGE
, "Close Tab\tCtrl+F4", "Close Tab")
285 self
._rmenu
.AppendItem(item
)
288 def LayoutItems(self
):
290 mainSizer
= wx
.BoxSizer(wx
.VERTICAL
)
291 self
.SetSizer(mainSizer
)
293 bookStyle
= fnb
.FNB_TABS_BORDER_SIMPLE
295 self
.book
= fnb
.StyledNotebook(self
, wx
.ID_ANY
, style
=bookStyle
)
296 self
.secondBook
= fnb
.StyledNotebook(self
, wx
.ID_ANY
, style
=bookStyle
)
298 # Set right click menu to the notebook
299 self
.book
.SetRightClickMenu(self
._rmenu
)
302 self
.book
.SetImageList(self
._ImageList
)
303 mainSizer
.Add(self
.book
, 6, wx
.EXPAND
)
305 # Add spacer between the books
306 spacer
= wx
.Panel(self
, -1)
307 spacer
.SetBackgroundColour(wx
.SystemSettings_GetColour(wx
.SYS_COLOUR_3DFACE
))
308 mainSizer
.Add(spacer
, 0, wx
.ALL | wx
.EXPAND
)
310 mainSizer
.Add(self
.secondBook
, 2, wx
.EXPAND
)
312 # Add some pages to the second notebook
315 text
= wx
.TextCtrl(self
.secondBook
, -1, "Second Book Page 1", style
=wx
.TE_MULTILINE
)
316 self
.secondBook
.AddPage(text
, "Second Book Page 1")
318 text
= wx
.TextCtrl(self
.secondBook
, -1, "Second Book Page 2", style
=wx
.TE_MULTILINE
)
319 self
.secondBook
.AddPage(text
, "Second Book Page 2")
328 def OnStyle(self
, event
):
330 style
= self
.book
.GetWindowStyleFlag()
331 eventid
= event
.GetId()
333 if eventid
== MENU_HIDE_NAV_BUTTONS
:
334 if event
.IsChecked():
335 # Hide the navigation buttons
336 style |
= fnb
.FNB_NO_NAV_BUTTONS
338 if style
& fnb
.FNB_NO_NAV_BUTTONS
:
339 style ^
= fnb
.FNB_NO_NAV_BUTTONS
341 self
.book
.SetWindowStyleFlag(style
)
343 elif eventid
== MENU_HIDE_X
:
344 if event
.IsChecked():
346 style |
= fnb
.FNB_NO_X_BUTTON
348 if style
& fnb
.FNB_NO_X_BUTTON
:
349 style ^
= fnb
.FNB_NO_X_BUTTON
351 self
.book
.SetWindowStyleFlag(style
)
353 elif eventid
== MENU_DRAW_BORDER
:
354 if event
.IsChecked():
355 style |
= fnb
.FNB_TABS_BORDER_SIMPLE
357 if style
& fnb
.FNB_TABS_BORDER_SIMPLE
:
358 style ^
= fnb
.FNB_TABS_BORDER_SIMPLE
360 self
.book
.SetWindowStyleFlag(style
)
362 elif eventid
== MENU_USE_MOUSE_MIDDLE_BTN
:
363 if event
.IsChecked():
364 style |
= fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
366 if style
& fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
:
367 style ^
= fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
369 self
.book
.SetWindowStyleFlag(style
)
371 elif eventid
== MENU_USE_BOTTOM_TABS
:
372 if event
.IsChecked():
373 style |
= fnb
.FNB_BOTTOM
375 if style
& fnb
.FNB_BOTTOM
:
376 style ^
= fnb
.FNB_BOTTOM
378 self
.book
.SetWindowStyleFlag(style
)
382 def OnQuit(self
, event
):
387 def OnDeleteAll(self
, event
):
389 self
.book
.DeleteAllPages()
392 def OnShowImages(self
, event
):
394 self
._bShowImages
= event
.IsChecked()
397 def OnVC71Style(self
, event
):
399 style
= self
.book
.GetWindowStyleFlag()
401 # remove old tabs style
402 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
405 style |
= fnb
.FNB_VC71
407 self
.book
.SetWindowStyleFlag(style
)
410 def OnVC8Style(self
, event
):
412 style
= self
.book
.GetWindowStyleFlag()
414 # remove old tabs style
415 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
421 self
.book
.SetWindowStyleFlag(style
)
424 def OnDefaultStyle(self
, event
):
426 style
= self
.book
.GetWindowStyleFlag()
428 # remove old tabs style
429 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
432 self
.book
.SetWindowStyleFlag(style
)
435 def OnFancyStyle(self
, event
):
437 style
= self
.book
.GetWindowStyleFlag()
439 # remove old tabs style
440 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
443 style |
= fnb
.FNB_FANCY_TABS
444 self
.book
.SetWindowStyleFlag(style
)
447 def OnSelectColor(self
, event
):
449 eventid
= event
.GetId()
451 # Open a color dialog
452 data
= wx
.ColourData()
454 dlg
= wx
.ColourDialog(self
, data
)
456 if dlg
.ShowModal() == wx
.ID_OK
:
458 if eventid
== MENU_SELECT_GRADIENT_COLOR_BORDER
:
459 self
.book
.SetGradientColorBorder(dlg
.GetColourData().GetColour())
460 elif eventid
== MENU_SELECT_GRADIENT_COLOR_FROM
:
461 self
.book
.SetGradientColorFrom(dlg
.GetColourData().GetColour())
462 elif eventid
== MENU_SELECT_GRADIENT_COLOR_TO
:
463 self
.book
.SetGradientColorTo(dlg
.GetColourData().GetColour())
464 elif eventid
== MENU_SET_ACTIVE_TEXT_COLOR
:
465 self
.book
.SetActiveTabTextColour(dlg
.GetColourData().GetColour())
466 elif eventid
== MENU_SELECT_NONACTIVE_TEXT_COLOR
:
467 self
.book
.SetNonActiveTabTextColour(dlg
.GetColourData().GetColour())
468 elif eventid
== MENU_SET_ACTIVE_TAB_COLOR
:
469 self
.book
.SetActiveTabColour(dlg
.GetColourData().GetColour())
470 elif eventid
== MENU_SET_TAB_AREA_COLOR
:
471 self
.book
.SetTabAreaColour(dlg
.GetColourData().GetColour())
476 def OnAddPage(self
, event
):
478 caption
= "New Page Added #" + str(self
._newPageCounter
)
483 if self
._bShowImages
:
484 image
= random
.randint(0, self
._ImageList
.GetImageCount()-1)
486 self
.book
.AddPage(self
.CreatePage(caption
), caption
, True, image
)
487 self
.book
.SetSelection(self
.book
.GetPageCount()-1)
489 self
._newPageCounter
= self
._newPageCounter
+ 1
492 def CreatePage(self
, caption
):
494 return wx
.TextCtrl(self
.book
, -1, caption
, wx
.DefaultPosition
, self
.book
.GetPageBestSize(),
498 def OnDeletePage(self
, event
):
500 self
.book
.DeletePage(self
.book
.GetSelection())
503 def OnSetSelection(self
, event
):
505 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to select:", "Set Selection")
507 if dlg
.ShowModal() == wx
.ID_OK
:
510 self
.book
.SetSelection(int(val
))
513 def OnEnableTab(self
, event
):
515 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to enable:", "Enable Tab")
517 if dlg
.ShowModal() == wx
.ID_OK
:
520 self
.book
.Enable(int(val
))
523 def OnDisableTab(self
, event
):
525 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to disable:", "Disable Tab")
527 if dlg
.ShowModal() == wx
.ID_OK
:
530 self
.book
.Enable(int(val
), False)
533 def OnEnableDrag(self
, event
):
535 style
= self
.book
.GetWindowStyleFlag()
537 if event
.IsChecked():
538 if style
& fnb
.FNB_NODRAG
:
539 style ^
= fnb
.FNB_NODRAG
541 style |
= fnb
.FNB_NODRAG
543 self
.book
.SetWindowStyleFlag(style
)
546 def OnSetAllPagesShapeAngle(self
, event
):
549 dlg
= wx
.TextEntryDialog(self
, "Enter an inclination of header borders (0-45):", "Set Angle")
550 if dlg
.ShowModal() == wx
.ID_OK
:
553 self
.book
.SetAllPagesShapeAngle(int(val
))
556 def OnSetPageImageIndex(self
, event
):
558 dlg
= wx
.TextEntryDialog(self
, "Enter an image index (0-%i):"%(self
.book
.GetImageList().GetImageCount()-1), "Set Image Index")
559 if dlg
.ShowModal() == wx
.ID_OK
:
561 self
.book
.SetPageImageIndex(self
.book
.GetSelection(), int(val
))
564 def OnAdvanceSelectionFwd(self
, event
):
566 self
.book
.AdvanceSelection(True)
569 def OnAdvanceSelectionBack(self
, event
):
571 self
.book
.AdvanceSelection(False)
574 def OnPageChanging(self
, event
):
576 print "Page Changing From", event
.GetOldSelection(), "To", event
.GetSelection()
580 def OnPageChanged(self
, event
):
582 print "Page Changed To", event
.GetSelection()
586 def OnPageClosing(self
, event
):
588 print "Page Closing, Selection:", event
.GetSelection()
592 def OnDrawTabX(self
, event
):
594 style
= self
.book
.GetWindowStyleFlag()
595 if event
.IsChecked():
596 style |
= fnb
.FNB_X_ON_TAB
598 if style
& fnb
.FNB_X_ON_TAB
:
599 style ^
= fnb
.FNB_X_ON_TAB
601 self
.book
.SetWindowStyleFlag(style
)
604 def OnDClickCloseTab(self
, event
):
606 style
= self
.book
.GetWindowStyleFlag()
607 if event
.IsChecked():
608 style |
= fnb
.FNB_DCLICK_CLOSES_TABS
610 style
&= ~
(fnb
.FNB_DCLICK_CLOSES_TABS
)
612 self
.book
.SetWindowStyleFlag(style
)
615 def OnGradientBack(self
, event
):
617 style
= self
.book
.GetWindowStyleFlag()
618 if event
.IsChecked():
619 style |
= fnb
.FNB_BACKGROUND_GRADIENT
621 style
&= ~
(fnb
.FNB_BACKGROUND_GRADIENT
)
623 self
.book
.SetWindowStyleFlag(style
)
627 def OnColorfulTabs(self
, event
):
629 style
= self
.book
.GetWindowStyleFlag()
630 if event
.IsChecked():
631 style |
= fnb
.FNB_COLORFUL_TABS
633 style
&= ~
(fnb
.FNB_COLORFUL_TABS
)
635 self
.book
.SetWindowStyleFlag(style
)
639 def OnAbout(self
, event
):
641 msg
= "This Is The About Dialog Of The FlatNotebook Demo.\n\n" + \
642 "Author: Andrea Gavana @ 02 Oct 2006\n\n" + \
643 "Please Report Any Bug/Requests Of Improvements\n" + \
644 "To Me At The Following Adresses:\n\n" + \
645 "andrea.gavana@gmail.com\n" + "gavana@kpo.kz\n\n" + \
646 "Based On Eran C++ Implementation (wxWidgets Forum).\n\n" + \
647 "Welcome To wxPython " + wx
.VERSION_STRING
+ "!!"
649 dlg
= wx
.MessageDialog(self
, msg
, "FlatNotebook wxPython Demo",
650 wx
.OK | wx
.ICON_INFORMATION
)
655 #---------------------------------------------------------------------------
658 class TestPanel(wx
.Panel
):
659 def __init__(self
, parent
, log
):
661 wx
.Panel
.__init
__(self
, parent
, -1)
663 b
= wx
.Button(self
, -1, " Test ButtonPanel ", (50,50))
664 self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
)
667 def OnButton(self
, evt
):
668 self
.win
= FlatNotebookDemo(self
, title
="FlatNotebook Demo")
671 #----------------------------------------------------------------------
673 def runTest(frame
, nb
, log
):
674 win
= TestPanel(nb
, log
)
677 #----------------------------------------------------------------------
680 overview
= fnb
.__doc
__
684 if __name__
== '__main__':
687 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])