- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 a Combobox in Tkinter?
The Combobox widget is similar to the OptionMenu widget in Tkinter which gives the user a choice to select from the group of options. The Combobox widget allows users to select the option with an Entry widget that adds selected menu items from the dropdown list.
We can Enable or Disable the options in the given Combobox widget by providing the state property. The state property forces to make a widget either active or disabled. To disable the Combobox widget, we have to set the state property as readonly or disabled.
#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") #Define a Label widget Label(win, text= "Select an Option from the List", font=('Aerial', 14, 'bold')).pack(pady=15) #Create a Combobox with list of items var= StringVar() my_combobox= ttk.Combobox(win, textvariable=var, values=["High", "Mid","Low"], state= 'disabled') my_combobox.pack() #Create a Button widget win.mainloop()
In the above code snippet, we have disabled the Combobox widget by disabling the state. Now, to make the widget fully functional, just change the state of the widget using state= ‘normal’.
- How to Disable / Enable a Button in TKinter?
- Set a default value for a ttk Combobox in Tkinter?
- How to gray out (disable) a Tkinter Frame?
- How to get the index of selected option in Tkinter Combobox?
- How to disable (grey out) a checkbutton in Tkinter?
- How to disable checkbutton Tkinter (grey out)?
- How to edit a comboBox in JavaFX?
- How to disable multiselection on Treeview in tkinter?
- How to disable an Entry widget in Tkinter?
- How can I disable typing in a ttk.Combobox tkinter?
- How to create a ComboBox using JavaFX?
- How to hide or disable the mouse pointer in Tkinter?
- Disable Exit (or [ X ]) in Tkinter Window
- How to right align the text in a ComboBox in Java
- How to disable a JLabel in Java?