[英]Tkinter - How can I change the default Notebook border color?
下面是我的示例代碼:
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"
不起作用。 我使用了錯誤的指令嗎? 我該如何解決我的問題?
我認為這應該可以完成工作。 所以,當我讀到它時,您需要更改聚焦和非聚焦應用程序的背景顏色; 此外,對於無邊框,將高光厚度設置為 0(零):
from tkinter import *
root = Tk()
e = Entry(highlightthickness=2)
e.config(highlightbackground = "red", highlightcolor= "red")
e.pack()
root.mainloop()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.