您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Python 3中更改Notebook小部件的选项卡大小

在Python 3中更改Notebook小部件的选项卡大小

我想您想在ttk笔记本的标签中填充内容吗?

在这种情况下,您可以使用自定义样式,可以根据自己的喜好调整颜色填充等。

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
style = ttk.Style()
style.theme_create( "MyStyle", parent="alt", settings={
        "TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0] } },
        "TNotebook.Tab": {"configure": {"padding": [100, 100] },}})

style.theme_use("MyStyle")

a_notebook = ttk.Notebook(root, width=200, height=200)
a_tab = ttk.Frame(a_notebook)
a_notebook.add(a_tab, text = 'This is the first tab')
another_tab = ttk.Frame(a_notebook)
a_notebook.add(another_tab, text = 'This is another tab')
a_notebook.pack(expand=True, fill=tk.BOTH)

tk.Button(root, text='Some Text!').pack(fill=tk.X)

root.mainloop()
python 2022/1/1 18:25:45 有171人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶