
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
- Related Questions & Answers
- Set the color of the border with CSS
- How to set the color of the left border with JavaScript?
- How to set the color of the right border with JavaScript?
- How to set the color of the top border with JavaScript?
- How to change the color of certain words in a Tkinter text widget?
- How to set the color of an elements border with JavaScript?
- Set the color of the right border using CSS
- How to set the color of the bottom border in JavaScript DOM?
- 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 set border width, border style, and border color in one declaration with JavaScript?
- How to delete Tkinter widgets from a window?
Advertisements