How to set border color of certain Tkinter widgets?

◇◆丶佛笑我妖孽 提交于 2020-01-12 03:06:30

问题


I'm trying to change the background color of my Tkinter app, but for certain widgets it leaves a white border around the edges.

For example, this:

from tkinter import *

COLOR = "black"

root = Tk()
root.config(bg=COLOR)

button = Button(text="button", bg=COLOR)
button.pack(padx=5, pady=5)
entry = Entry(bg=COLOR, fg='white')
entry.pack(padx=5, pady=5)
text = Text(bg=COLOR, fg='white')
text.pack(padx=5, pady=5)

root.mainloop()

How can I set border colour of certain Tkinter widgets?


回答1:


Just use

widget.config(highlightbackground=COLOR)

Furthermore, if you don't want that border at all, set the highlightthickness attribute to 0 (zero).



来源:https://stackoverflow.com/questions/4320725/how-to-set-border-color-of-certain-tkinter-widgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!