gpt4 book ai didi

python - 在中心设置 ttk Notebook 标签 [Python]

转载 作者:行者123 更新时间:2023-12-04 09:33:02 24 4
gpt4 key购买 nike

我想使用 ttk Notebooks 在 python/tkinter 应用程序中创建自己的风格。我喜欢下面显示的浅绿色设置的风格。

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
s = ttk.Style(root)
s.theme_use('aqua')

notebook = ttk.Notebook(root)
frame1 = ttk.Frame(root, width=400, height=400)
frame2 = ttk.Frame(root)
notebook.add(frame1, text="Frame1")
notebook.add(frame2, text="Frame2")
notebook.pack()

root.geometry("400x400")
root.mainloop()
aqua theme
但是 aqua 不允许我更改某些小部件的背景颜色,因此我想使用默认样式。有没有办法使用默认样式配置 TNotebook.Tab 以获取中间的选项卡?就像是
s.configure('TNotebook.Tab', tabposition='center')
但我还没有找到任何有效的方法。

最佳答案

我无法使用主题 aqua在 Windows 上,但使用默认主题和

s.configure("TNotebook", tabposition='n')
可以在中心制作标签。
enter image description here

关于python - 在中心设置 ttk Notebook 标签 [Python],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62736799/

24 4 0