在 Python 3 中更改 Notebook 小部件的选项卡大小 [英] Changing the tab sizes of a Notebook widget in Python 3

查看:27
本文介绍了在 Python 3 中更改 Notebook 小部件的选项卡大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改 tkinter Notebook 小部件中选项卡的大小,但我找不到任何实际更改选项卡宽度和高度的内容.没有直接的方法可以改变它们吗?或者有什么方法可以绕过它?如果有任何改变,我目前正在使用 python 3.

I'm trying to change the size of the tabs in a tkinter Notebook widget, but I haven't been able to find anything that actually changes the width and height of the tabs. Is there not a direct way to change them? Or is there some way to get around it? I'm currently using python 3 if that changes anything.

推荐答案

我想你想在 ttk 笔记本的标签页中填充?

I think you want padding in the ttk notebook's tabs?

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

In which case you can use a custom style, which you can adjust to your taste for colors padding etc.

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 3 中更改 Notebook 小部件的选项卡大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆