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
, log
):
75 wx
.Frame
.__init
__(self
, parent
, title
="FlatNotebook Demo", size
=(800,600))
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")
327 def OnStyle(self
, event
):
329 style
= self
.book
.GetWindowStyleFlag()
330 eventid
= event
.GetId()
332 if eventid
== MENU_HIDE_NAV_BUTTONS
:
333 if event
.IsChecked():
334 # Hide the navigation buttons
335 style |
= fnb
.FNB_NO_NAV_BUTTONS
337 if style
& fnb
.FNB_NO_NAV_BUTTONS
:
338 style ^
= fnb
.FNB_NO_NAV_BUTTONS
340 self
.book
.SetWindowStyleFlag(style
)
342 elif eventid
== MENU_HIDE_X
:
343 if event
.IsChecked():
345 style |
= fnb
.FNB_NO_X_BUTTON
347 if style
& fnb
.FNB_NO_X_BUTTON
:
348 style ^
= fnb
.FNB_NO_X_BUTTON
350 self
.book
.SetWindowStyleFlag(style
)
352 elif eventid
== MENU_DRAW_BORDER
:
353 if event
.IsChecked():
354 style |
= fnb
.FNB_TABS_BORDER_SIMPLE
356 if style
& fnb
.FNB_TABS_BORDER_SIMPLE
:
357 style ^
= fnb
.FNB_TABS_BORDER_SIMPLE
359 self
.book
.SetWindowStyleFlag(style
)
361 elif eventid
== MENU_USE_MOUSE_MIDDLE_BTN
:
362 if event
.IsChecked():
363 style |
= fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
365 if style
& fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
:
366 style ^
= fnb
.FNB_MOUSE_MIDDLE_CLOSES_TABS
368 self
.book
.SetWindowStyleFlag(style
)
370 elif eventid
== MENU_USE_BOTTOM_TABS
:
371 if event
.IsChecked():
372 style |
= fnb
.FNB_BOTTOM
374 if style
& fnb
.FNB_BOTTOM
:
375 style ^
= fnb
.FNB_BOTTOM
377 self
.book
.SetWindowStyleFlag(style
)
381 def OnQuit(self
, event
):
386 def OnDeleteAll(self
, event
):
388 self
.book
.DeleteAllPages()
391 def OnShowImages(self
, event
):
393 self
._bShowImages
= event
.IsChecked()
396 def OnVC71Style(self
, event
):
398 style
= self
.book
.GetWindowStyleFlag()
400 # remove old tabs style
401 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
404 style |
= fnb
.FNB_VC71
406 self
.book
.SetWindowStyleFlag(style
)
409 def OnVC8Style(self
, event
):
411 style
= self
.book
.GetWindowStyleFlag()
413 # remove old tabs style
414 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
420 self
.book
.SetWindowStyleFlag(style
)
423 def OnDefaultStyle(self
, event
):
425 style
= self
.book
.GetWindowStyleFlag()
427 # remove old tabs style
428 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
431 self
.book
.SetWindowStyleFlag(style
)
434 def OnFancyStyle(self
, event
):
436 style
= self
.book
.GetWindowStyleFlag()
438 # remove old tabs style
439 mirror
= ~
(fnb
.FNB_VC71 | fnb
.FNB_VC8 | fnb
.FNB_FANCY_TABS
)
442 style |
= fnb
.FNB_FANCY_TABS
443 self
.book
.SetWindowStyleFlag(style
)
446 def OnSelectColor(self
, event
):
448 eventid
= event
.GetId()
450 # Open a color dialog
451 data
= wx
.ColourData()
453 dlg
= wx
.ColourDialog(self
, data
)
455 if dlg
.ShowModal() == wx
.ID_OK
:
457 if eventid
== MENU_SELECT_GRADIENT_COLOR_BORDER
:
458 self
.book
.SetGradientColorBorder(dlg
.GetColourData().GetColour())
459 elif eventid
== MENU_SELECT_GRADIENT_COLOR_FROM
:
460 self
.book
.SetGradientColorFrom(dlg
.GetColourData().GetColour())
461 elif eventid
== MENU_SELECT_GRADIENT_COLOR_TO
:
462 self
.book
.SetGradientColorTo(dlg
.GetColourData().GetColour())
463 elif eventid
== MENU_SET_ACTIVE_TEXT_COLOR
:
464 self
.book
.SetActiveTabTextColour(dlg
.GetColourData().GetColour())
465 elif eventid
== MENU_SELECT_NONACTIVE_TEXT_COLOR
:
466 self
.book
.SetNonActiveTabTextColour(dlg
.GetColourData().GetColour())
467 elif eventid
== MENU_SET_ACTIVE_TAB_COLOR
:
468 self
.book
.SetActiveTabColour(dlg
.GetColourData().GetColour())
469 elif eventid
== MENU_SET_TAB_AREA_COLOR
:
470 self
.book
.SetTabAreaColour(dlg
.GetColourData().GetColour())
475 def OnAddPage(self
, event
):
477 caption
= "New Page Added #" + str(self
._newPageCounter
)
482 if self
._bShowImages
:
483 image
= random
.randint(0, self
._ImageList
.GetImageCount()-1)
485 self
.book
.AddPage(self
.CreatePage(caption
), caption
, True, image
)
486 self
.book
.SetSelection(self
.book
.GetPageCount()-1)
488 self
._newPageCounter
= self
._newPageCounter
+ 1
491 def CreatePage(self
, caption
):
493 p
= wx
.Panel(self
.book
)
494 wx
.StaticText(p
, -1, caption
, (20,20))
495 wx
.TextCtrl(p
, -1, "", (20,40), (150,-1))
496 #wx.TextCtrl(p, -1, "", (20,75), (150,-1), style=wx.TE_MULTILINE)
501 def OnDeletePage(self
, event
):
503 self
.book
.DeletePage(self
.book
.GetSelection())
506 def OnSetSelection(self
, event
):
508 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to select:", "Set Selection")
510 if dlg
.ShowModal() == wx
.ID_OK
:
513 self
.book
.SetSelection(int(val
))
516 def OnEnableTab(self
, event
):
518 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to enable:", "Enable Tab")
520 if dlg
.ShowModal() == wx
.ID_OK
:
523 self
.book
.Enable(int(val
))
526 def OnDisableTab(self
, event
):
528 dlg
= wx
.TextEntryDialog(self
, "Enter Tab Number to disable:", "Disable Tab")
530 if dlg
.ShowModal() == wx
.ID_OK
:
533 self
.book
.Enable(int(val
), False)
536 def OnEnableDrag(self
, event
):
538 style
= self
.book
.GetWindowStyleFlag()
540 if event
.IsChecked():
541 if style
& fnb
.FNB_NODRAG
:
542 style ^
= fnb
.FNB_NODRAG
544 style |
= fnb
.FNB_NODRAG
546 self
.book
.SetWindowStyleFlag(style
)
549 def OnSetAllPagesShapeAngle(self
, event
):
552 dlg
= wx
.TextEntryDialog(self
, "Enter an inclination of header borders (0-45):", "Set Angle")
553 if dlg
.ShowModal() == wx
.ID_OK
:
556 self
.book
.SetAllPagesShapeAngle(int(val
))
559 def OnSetPageImageIndex(self
, event
):
561 dlg
= wx
.TextEntryDialog(self
, "Enter an image index (0-%i):"%(self
.book
.GetImageList().GetImageCount()-1), "Set Image Index")
562 if dlg
.ShowModal() == wx
.ID_OK
:
564 self
.book
.SetPageImageIndex(self
.book
.GetSelection(), int(val
))
567 def OnAdvanceSelectionFwd(self
, event
):
569 self
.book
.AdvanceSelection(True)
572 def OnAdvanceSelectionBack(self
, event
):
574 self
.book
.AdvanceSelection(False)
577 def OnPageChanging(self
, event
):
578 self
.log
.write("Page Changing From %d To %d" % (event
.GetOldSelection(), event
.GetSelection()))
582 def OnPageChanged(self
, event
):
583 self
.log
.write("Page Changed To %d" % event
.GetSelection())
587 def OnPageClosing(self
, event
):
588 self
.log
.write("Page Closing, Selection: %d" % 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 FlatNotebook ", (50,50))
664 self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
)
667 def OnButton(self
, evt
):
668 self
.win
= FlatNotebookDemo(self
, self
.log
)
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:])