In 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]
Advertisement
Answer
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.