2

enter image description hereIn the below program i have many tabs in a single notebook page. when the number of tabs increases the look changes. So how to put the tabs in different rows

As in attached image, I have many tabs in a single row, but I want some tabs say from JJJJ in a below row.

How to set tabs in different row also how to give different colors to tab(highlight the tab) when selected?

title = 'Trial Tool window'

import sys
sys.path[:0] = ['../../..']

import Tkinter
import Pmw

class MyButton(Tkinter.Button):
    def __init__(self, master=None, cnf={}, **kw):
        self.__toggle = 0
        kw['background'] = 'green'
        kw['activebackground'] = 'red'
        apply(Tkinter.Button.__init__, (self, master, cnf), kw)


class Demo:
    def __init__(self, parent):
    # Create and pack the NoteBook.
        notebook = Pmw.NoteBook(parent)
        notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)

        page = notebook.add('AAAA')
        notebook.tab('AAAA').focus_set()

        # Create the "Toolbar" contents of the page.
        group = Pmw.Group(page, tag_text = 'XYZ')
        group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
        b1 = Tkinter.Checkbutton(group.interior(), text = 'Show tool')
        b1.grid(row = 0, column = 0)

        # Add all other Channel pages.
        page = notebook.add('BBBB')
        page = notebook.add('CCCC')
        page = notebook.add('DDDD')
        page = notebook.add('EEEE')
        page = notebook.add('FFFF')
        page = notebook.add('GGGG')
        page = notebook.add('HHHH')
        page = notebook.add('IIII')
        page = notebook.add('JJJJ')
        page = notebook.add('KKKK')
        page = notebook.add('LLLL')
        page = notebook.add('MMMM')
        page = notebook.add('NNNN')
        page = notebook.add('OOOO')
        page = notebook.add('PPPP')
        page = notebook.add('QQQQ')
        page = notebook.add('RRRR')

        notebook.setnaturalsize()

######################################################################

# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root)
    root.title(title)

    widget = Demo(root)

    exitButton = MyButton(root, text = 'Exit', command = root.destroy)
    exitButton.pack()
    root.mainloop()![enter image description here][2]
nbro
  • 15,395
  • 32
  • 113
  • 196
Ds Arjun
  • 409
  • 2
  • 7
  • 16
  • I think it is not possibile to do, according to this post: http://stackoverflow.com/questions/11387362/is-there-a-way-to-set-tabs-of-a-notebook-below-one-another. You might want to create your own Notebook widget (not advisable if you don't have a good understanding of pack/grid layout management and a good knowledge of some important widgets, such as labels, frames and buttons) or just stick with this style. Anyway, I don't think you will have more than 10 tabs opened, in general, at least me. – nbro May 30 '15 at 22:36
  • I have one more doubt, in notebook is there any chance of highlighting the active tab? – Ds Arjun Jun 02 '15 at 19:39
  • I am sorry, I have used it just one or 2 times and I don't remember. I know you can specify your own `Style` for the Notebook widget, it's not so straight forward, but it might worth reading the documention and try to see if you can do it. Specifically, you should read about "how to apply styles to ttk widgets"... – nbro Jun 02 '15 at 19:54

1 Answers1

1

It is not possible with ttk to do this and it is a horrible design anyway. Instead, create an "options dialog" where you put either a list or a treeview in a panel on the side and use that to select among your many subpages. You can then use a notebook without tabs or simply switch in different frames containing your child pages in response to clicks on the selection pane.

Search google images for "options dialog" to see any number of implementations of this scheme. Multiple rows of tabs is a really bad design from a usability perspective.

patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • Yes now I feel what you said is correct. Now I will create selection pane in which I will add check boxes to enable or disable tabs. Thanks for the idea. – Ds Arjun Jun 15 '15 at 19:41