Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set border color of certain Tkinter widgets?

People also ask

How do I change the border color of a widget?

There is no way to change the border color of a widget, the border color is tied to the background color of the widget. Instead, you can turn off the border, and then use a frame widget where you can set the background color of the frame.

What we used to change the background Colour any widget in Python?

We can customize the tkinter widgets using the tkinter. ttk module. Tkinter. ttk module is used for styling the tkinter widgets such as setting the background color, foreground color, activating the buttons, adding images to labels, justifying the height and width of widgets, etc.

How do you add a background color to a frame in Python?

Build A Paint Program With TKinter and Python In order to change the background color and foreground color of a tkinter frame, we can assign different values to the bg and fg parameters in the Frame function.

What is FG in Tkinter widget means?

foreground − Foreground color for the widget. This can also be represented as fg.


Just use

widget.config(highlightbackground=COLOR)

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


You have to set the two highlights (with and without focus) to have a continuous color.

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