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.
# 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()
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 −