- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the border color of certain Tkinter widgets?
Let us suppose we want to change the border color of a tkinter widget. We can configure the widget by passing the highlightcolor, highlightbackground property of the widget.
In this example, we have created an Entry widget and a button that can be triggered to change the border color of the Entry Widget.
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") #Define a function to change the color of entry widget def change_color(): text.config(highlightthickness=2, highlightbackground="red") #Create a Entry widget for which we want to change the border color text= Entry(win, width= 50) text.pack() #Create a Button Widget button= Button(win, text= "Change", command=change_color) button.pack(pady=20) win.mainloop()
Running the above code will display a window that contains a button which can be used to change the border color of the entry widget.
Now click on “Change” Button to change the border color of Widget.
- Set the color of the border with CSS
- How to change the color of certain words in a Tkinter text widget?
- Set the color of the right border using CSS
- How to set the background color of a ttk.Combobox in tkinter?
- How to create transparent widgets using Tkinter?
- How to set padding of all widgets inside a window or frame in Tkinter?
- How to set border color for SoftBevelBorder in Java?
- How to set the border color of the dots in matplotlib's scatterplots?
- How to delete Tkinter widgets from a window?