- 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 disable checkbutton Tkinter (grey out)?
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.
Example
#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()
Output
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’.
Advertisements