Why do the `tkinter.ttk.Notebook` tabs get thinner and thinner?

怎甘沉沦 提交于 2019-12-11 04:43:12

问题


I am using a tkinter.ttk.Notebook and the tabs seem to get thinner with time. How do I overcome this? Is there a possibility to specify a uniform width for each tab?

I use this code to add a tab:

notebook.add(game.frame, text=game.name, underline=0, sticky=tkinter.NS)

回答1:


I don't know if it's possible to set a uniform width for each tab, but it seems that the tab width problem is style dependent:

  • with style "alt" the tab name SEVEN is partially hidden:
  • with style "clam" it is fully visible:

Here is how to change style of the whole window:

sty = ttk.Style() 
sty.theme_use(theme_name)

To get the list of all theme names: sty.theme_names().

You can get more information on ttk styles here http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-theme-layer.html.



来源:https://stackoverflow.com/questions/38243547/why-do-the-tkinter-ttk-notebook-tabs-get-thinner-and-thinner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!