I got it partially working… The issue is going through the tabs in reverse…
import wx
import wx.lib.agw.labelbook as LB
class MyLabelBook(LB.LabelBook):
def init(self, parent, *args, **kw):
LB.LabelBook.init(self, parent, *args, **kw)
class MyFrame(wx.Frame):
def init(self, parent):
wx.Frame.init(self, parent, -1, “LabelBook Demo”)
self.notebook = LB.LabelBook(self, -1, agwStyle=LB.INB_FIT_LABELTEXT|LB.INB_LEFT|LB.INB_DRAW_SHADOW|LB.INB_GRADIENT_BACKGROUND)
pane_1 = wx.Panel(self.notebook)
pane_2 = wx.Panel(self.notebook)
imagelist = wx.ImageList(32, 32)
self.notebook.AssignImageList(imagelist)
self.notebook.AddPage(pane_1, “Tab1”, 1, 0)
self.notebook.AddPage(pane_2, “Tab2”, 0, 0)
self.notebook.AddPage(pane_2, “Tab3”, 0, 0)
self.notebook.AddPage(pane_2, “Tab4”, 0, 0)
self.notebook.EnableTab(2, False)
self.notebook.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)
def OnNavigationKey(self, event):
if event.IsWindowChange():
if self.notebook.GetPageCount() == 0:
return
self._new_AdvanceSelection(event.GetDirection())
else:
event.Skip()
def _new_AdvanceSelection(self, forward=True):
nSel = self.notebook.GetSelection()
if nSel < 0:
return
nMax = self.notebook.GetPageCount() - 1
if forward:
newSelection = (nSel == nMax and [0] or [nSel + 1])[0]
if not self.notebook.GetEnabled(newSelection):
newSelection = (nSel == nMax and [0] or [nSel + 2])[0]
else:
newSelection = (nSel == 0 and [nMax] or [nSel - 1])[0]
if not self.notebook.GetEnabled(newSelection):
newSelection = (nSel == nMax and [0] or [nSel - 1])[0] # Tried -2, and others… doesn’t work.
self.notebook.SetSelection(newSelection)
def Main():
app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
if name == ‘main’:
Main()
Any suggestions?
···
On Thursday, January 30, 2014 4:19:19 PM UTC-5, Mike Stover wrote:
Greetings,
I would like to use ditch the menu bar from an application I am writing in favor of LabelBook, however I’ve run into a bit of a snag. I would like to have 4 Tabs, a spacer, then 2 more tabs. I have been able to add a “spacer” by creating an empty page, then disabling the tab for it. The problem with this method is I lose the ctrl+tab navigation once I reach the 4th tab. Basically Ctrl+Tab will no longer advance due to the disabled tab being next in the Tab order.
Is there a better way to add a spacer, or a way to skip the disabled tab? I’m not looking for exact code, just to be pointed in the right direction.
Thanks,
-Mike S
(PS: I would add an example image or code but this computer is flaking out when it tries to connect to my Google Drive)