Cannot view all tabs in ttk.Notebook

I have some problems with tabs of the ttk Notebook class in python 2.7. I do not see all the tabs that I create.

I made the 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 see is

this

I tried changing the number of tabs, and I noticed that the size of the top tab bar changes, and if there is only one single tab, I cannot see all of them, as you can see:

that

What I tried did nothing:

  • Tab Width Adjustment
  • Moving .pack () around
  • Adding .pack () to tabs
  • Using ttk.Frame instead of tk.Frame
  • Googling for a similar problem

What I tried worked, but not what I want:

  • Do not use tabs (too many things to show)
  • Only one tab available

I would be grateful for any help, thanks!

+5
source share
1 answer

So, I really fixed your problem, I have no idea why tk is doing this. I decided to overlap this tab by increasing the length of the tab text. I changed this part 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 it! Someone who is more experienced with tk can probably tell you why.

+2
source

Source: https://habr.com/ru/post/1246159/


All Articles