MENU_ENABLE_DRAG_N_DROP = wx.NewId()
MENU_DCLICK_CLOSES_TAB = wx.NewId()
MENU_USE_VC8_STYLE = wx.NewId()
+MENU_HIDE_ON_SINGLE_TAB = wx.NewId()
MENU_SET_ACTIVE_TEXT_COLOR = wx.NewId()
MENU_DRAW_TAB_X = wx.NewId()
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_ON_SINGLE_TAB, "Hide Page Container when only one Tab",
+ "Hide Page Container when only one Tab", wx.ITEM_CHECK)
+ self.Bind(wx.EVT_MENU, self.OnStyle, item)
+ self._editMenu.AppendItem(item)
+
item = wx.MenuItem(self._editMenu, MENU_HIDE_NAV_BUTTONS, "Hide Navigation Buttons",
"Hide Navigation Buttons", wx.ITEM_CHECK)
self._editMenu.AppendItem(item)
self.book.SetWindowStyleFlag(style)
+ elif eventid == MENU_HIDE_ON_SINGLE_TAB:
+ if event.IsChecked():
+ # Hide the navigation buttons
+ style |= fnb.FNB_HIDE_ON_SINGLE_TAB
+ else:
+ style &= ~(fnb.FNB_HIDE_ON_SINGLE_TAB)
+
+ self.book.SetWindowStyleFlag(style)
+
elif eventid == MENU_HIDE_X:
if event.IsChecked():
# Hide the X button
additional style that (un)checks a parent when all children are
(un)checked, i.e. TR_AUTO_CHECK_PARENT.
+wx.animate.AnimationCtrl fixed to display inactive bitmap at start
+(patch 1590192)
+
+Patch from Dj Gilcrease adding the FNB_HIDE_ON_SINGLE_TAB flag for
+wx.lib.flatnotebook.
+
+
FNB_ALLOW_FOREIGN_DND = 32768
"""Allows drag 'n' drop operations between different L{FlatNotebook}s"""
+FNB_HIDE_ON_SINGLE_TAB = 65536
+"""Hides the Page Container when there is one or fewer tabs"""
+
VERTICAL_BORDER_PADDING = 4
# Button size is a 16x16 xpm bitmap
FNB_NOWHERE = 0 # Anywhere else
"""Indicates mouse coordinates not on any tab of the notebook"""
-FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS
+FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS | FNB_HIDE_ON_SINGLE_TAB
"""L{FlatNotebook} default style"""
# FlatNotebook Events:
# refreshing the tab container is not enough
self.SetSelection(self._pages._iActivePage)
+ if not self._pages.HasFlag(FNB_HIDE_ON_SINGLE_TAB):
+ #For Redrawing the Tabs once you remove the Hide tyle
+ self._pages._ReShow()
+
def RemovePage(self, page):
""" Deletes the specified page, without deleting the associated window. """
pass
+ def _ReShow(self):
+ """ Handles the Redraw of the tabs when the FNB_HIDE_ON_SINGLE_TAB has been removed """
+ self.Show()
+ self.GetParent()._mainSizer.Layout()
+ self.Refresh()
+
+
def OnPaint(self, event):
""" Handles the wx.EVT_PAINT event for L{PageContainer}."""
renderer = self._mgr.GetRenderer(self.GetParent().GetWindowStyleFlag())
renderer.DrawTabs(self, dc)
+ if self.HasFlag(FNB_HIDE_ON_SINGLE_TAB) and len(self._pagesInfoVec) <= 1:
+ self.Hide()
+ self.GetParent()._mainSizer.Layout()
+ self.Refresh()
+
def AddPage(self, caption, selected=True, imgindex=-1):
"""