- Trending Categories
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 update a Button widget in Tkinter?
We can update a Button widget in Tkinter in various ways, for example, we can change its size, change its background color, or remove its border, etc. In the following example, we will create three Button widgets and each of the buttons, upon clicking, will call a different function to update their features.
Example
# Import the required library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win = Tk() # Define geometry of the window win.geometry("700x300") # Function to Increase the Size of the Button def Button_Size(): button1.configure(font=('Calibri 20 bold')) # Function to change the background color def Button_Color(): button2.configure(bg='green') # Function to Remove Border def Button_Border(): button3.configure(borderwidth=0) # First Button button1=Button(win, text="Increase the Button Size", command=Button_Size) button1.pack(pady=20) # Second Button button2=Button(win, text="Change the Background Color", command=Button_Color) button2.pack(pady=20) # Third Button button3 = Button(win, text="Remove the Border", command=Button_Border) button3.pack(pady=20) win.mainloop()
Output
Upon execution, it will first show the following window −
When you click "Increase the Button Size", it will produce the following output −
Upon clicking "Change the Background Color", it will produce the following output −
If you click "Remove the Border", it will produce the following output −
- Related Articles
- How to update a Python/tkinter label widget?
- How to make a Button using the Tkinter Canvas widget?
- How to update the image of a Tkinter Label widget?
- Get the text of a button widget in Tkinter
- How to clear the Entry widget after a button is pressed in Tkinter?
- How to get the value of a button in the Entry widget using Tkinter?
- How to center a Tkinter widget?
- How to make a Tkinter widget invisible?
- How to set the text/value/content of an 'Entry' widget using a button in Tkinter?
- How to see if a widget exists in Tkinter?
- How to create hyperlink in a Tkinter Text widget?
- How to highlight text in a tkinter Text widget?
- How to remove focus from a Tkinter widget?
- How to center a Tkinter widget in a sticky frame?
- How to implement Android button Sheet widget?

Advertisements