- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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.
Example
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()
Output
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.
Advertisements