Morb
Morb

Reputation: 534

Cannot see all tabs in ttk.Notebook

I have some trouble with the tabs from the ttk Notebook class in python 2.7. I cannot see all the tabs I create.

I made a minimal code to view the problem:

from Tkinter import *
import ttk

root = Tk()
nb = ttk.Notebook(root, width=320, height=240)
nb.pack(fill=BOTH, expand=1)
page0 = Frame(nb)
page1 = Frame(nb)
page2 = Frame(nb)
page3 = Frame(nb)
page4 = Frame(nb)
nb.add(page0, text="0")
nb.add(page1, text="1")
nb.add(page2, text="2")
nb.add(page3, text="3")
nb.add(page4, text="4")

root.mainloop()

All I can see is

this

I tried to change the number of tabs and I noticed the size of the top tab bar changes and unless there's only one single lonely tab, I cannot see all of them, as you can see:

that

What I tried that didn't do anything:

What I tried that worked but isn't what I want:

I'll appreciate any help, thanks!

Upvotes: 5

Views: 1205

Answers (1)

Dzhao
Dzhao

Reputation: 693

So I did fix your issue however, I have no idea why tk is doing this. I solved this tab over-lapping by increasing the length of the tab text. I changed this portion of your code:

nb.add(page0, text="long_name1")
nb.add(page1, text="long_name2")
nb.add(page2, text="long_name3")
nb.add(page3, text="long_name4")
nb.add(page4, text="long_name5")

Once again I don't know why tk does this! Someone that is more experienced with tk could probably tell you why.

Upvotes: 2

Related Questions