Tkinter provides Button widgets to create a button for triggering an event. Let us suppose we have created a button that is already disabled in an application. In order to change the state of the button, we can use the state property.
The state property is used to enable and disable a button in an application. In order to change the state of the application, we have two operations: state=DISABLED and state=NORMAL.
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("650x450") #Define a function for Button Object def quit_win(): win.destroy() #Create a button to quit the window Button(win,text="Quit", command=quit_win, font=('Helvetica bold',20), state= NORMAL).pack(pady=5) win.mainloop()
The output when the button is disabled,
Output when Button state=NORMAL