简体   繁体   中英

Tkinter - How can I change the default Notebook border color?

Below is my example code:

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()

my goal is change the default border color in "#848a98" but the option highlightbackground="#848a98" doesn't work. am I using the wrong instruction? how can I solve my issue?

在此处输入图片说明

I think this should do the work. So, as I read it, you need to change the color of the background for focused and not-focused apps; also, for no borders, set the highlight thickness to 0 (ZERO):

from tkinter import *
root = Tk()
e = Entry(highlightthickness=2)
e.config(highlightbackground = "red", highlightcolor= "red")
e.pack()
root.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM