Tkinter Checkbutton – Disable
We can disable a Checkbutton widget in Tkinter using state option.
To disable a Checkbutton widget in Tkinter, set its state option to DISABLED.
For example, in the following code snippet, we have created a Checkbutton which is disabled by setting the state option with tk.DISABLED.
tk.Checkbutton(window, text="Option 1", state=tk.DISABLED)
You can also disable the Checkbutton after creating it, by setting the state option as shown below.
checkbutton_1 = tk.Checkbutton(window, text="Option 1")
checkbutton_1['state'] = tk.DISABLED
In this tutorial, you will learn how to disable a Checkbutton using state option, with examples.
Example
In the following GUI application, we shall create a Checkbutton widget, and disable it using state option.
Python Program
import tkinter as tk
# Create the main window
window = tk.Tk()
window.geometry("300x200")
window.title("PythonExamples.org")
# Create the checkbutton widget
checkbutton_1 = tk.Checkbutton(window, text="Option 1")
# Disable the Checkbutton
checkbutton_1['state'] = tk.DISABLED
# Pack the checkbutton widget
checkbutton_1.pack()
# Start the Tkinter event loop
window.mainloop()
CopyOutput in MacOS
Summary
In this Python Tkinter tutorial, we have seen how to disable a Checkbutton widget, with examples.