Vertical tab text in wxNotebook

Ramashish Baranwal ramashish.lists at gmail.com
Mon Feb 11 22:26:30 PST 2008


> > Hi,
> >
> > I am using wxPython and want to create a wx.Notebook with tabs on left
> > side, but with vertical tab text orientation. I have found that the
> > tabs can be put on left side by specifying wx.NB_LEFT as style. How
> > can I (if possible) make the orientation of tab title text vertical
> > instead of horizontal?
>
> Doesn't it do that by default?  Which platform are you on?  Which
> version of wxPython?
>
No, it doesn't. Here is my sample code-

class MyPage(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "This is a Page object", (20,20))

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, title="Simple Notebook Example")

        # Here we create a panel and a notebook on the panel
        p = wx.Panel(self)
        nb = wx.Notebook(p, style=wx.NB_LEFT)

        # create the page windows as children of the notebook
        page1 = MyPage(nb)
        page2 = MyPage(nb)
        page3 = MyPage(nb)

        # add the pages to the notebook with the label to show on the tab
        nb.AddPage(page1, "Page 1")
        nb.AddPage(page2, "Page 2")
        nb.AddPage(page3, "Page 3")

        # finally, put the notebook in a sizer for the panel to manage
        # the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)
        p.SetSizer(sizer)

The tab title texts are shown on left side but with horizontal orientation e.g.-

Page 1
---------
Page 2
---------
Page 3

I am on Linux (Fedora 7), with wxPython version 2.8.4.0.

Thanks,
Ram




More information about the wx-users mailing list