The state property in Tkinter is used to change the state of any specific widget. We can make a widget either active or disabled whenever required. To disable the Checkbuttons widget, we have to set the state property as readonly or disabled. Changing the state will make all the checkbuttons inactive during the execution of the program.
#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter Frame win.geometry("750x250") #Add a Top widget Label(win,text= "Select an Option from the Menu", font=('Aerial', 15, 'bold')).pack(pady=15) #Define CheckButtons option_dict={} values=["C++", "Python", "JavaScript", "Ruby","GoLang"] for i in values: cb= ttk.Checkbutton(win, text=i,state= "disabled") cb.pack() #Create a Button widget win.mainloop()
In the above code snippet, we have disabled all the Checkbuttons Options by disabling its state. To make the Checkbuttons fully functional, we can change the state to state=‘normal’.