【发布时间】:2021-01-20 14:13:13
【问题描述】:
下面是我的示例代码:
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry("400x300")
style=ttk.Style()
style.configure("TNotebook", highlightbackground="#848a98") # if I use another option like - background="#848a98" - the style changes, but with - highlightbackground="#848a98" - option the style doesn't change..
MainNotebook = ttk.Notebook(root, style="TNotebook")
MainNotebook.place(x=16, y=16)
Frame1=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame1.pack()
Frame2=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame2.pack()
MainNotebook.add(Frame1, text="Tab1")
MainNotebook.add(Frame2, text="Tab2")
root.mainloop()
我的目标是更改 "#848a98" 中的默认边框颜色,但选项 highlightbackground="#848a98" 不起作用。我使用了错误的指令吗?我该如何解决我的问题?
【问题讨论】:
-
请提供minimal reproducible example,而不是给我们一个小的sn-p。它不需要比您发布的内容多很多,但它应该是完整的。
-
@Bryan Oakley:我只是改变了我的例子。现在已经完成了。
-
@Bryan Oakley: ciao Bryan,确定一下,你不知道如何解决这个问题吗?
-
这很神秘,tkinter i它是使用最多的组件,文档最差。
-
@e-info128 Tkinter 是一个很棒的工具。它已经集成在 Python 中,使用简单,并以“灵活”许可证发布,但我要说,它不适合专业作品!我研究并使用它大约一年,我发现了很多问题。最重要的是这两个:stackoverflow.com/questions/65137135/…stackoverflow.com/questions/66879948/…