

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 can I disable typing in a ttk.Combobox tkinter?
The ttk.Combobox is used to create dropdown menus in the Entry Widgets. To create the options, we just simply pass the strings to the values object of combobox. We can disable the combobox by passing the state as “readonly”.
Example
In the following example, we will create a combobox whose state is disabled.
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter window win.geometry("750x250") #Create an instance of StringVar var= StringVar() #Create an Label Label(win, text="Select any Language", font= ('Helvetica 15 bold')).pack(pady=20) #Create Object of Tkinter Combobox combobox= ttk.Combobox(win, textvariable= var, values=["C++","Java","Python","Rust","Go","JavaScript"]) combobox.pack() win.mainloop()
Output
Running the above code will display a window containing a combobox menu. We can select any option in the dropdown list.
Now add state = "readonly" in the Combobox object, it will make the Combobox Entry Widget disabled.
- Related Questions & Answers
- How to disable a Combobox in Tkinter?
- Set a default value for a ttk Combobox in Tkinter?
- How can I disable/enable GPS programmatically in android?
- How to Disable / Enable a Button in TKinter?
- Configure tkinter/ttk widgets with transparent backgrounds
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)
- How to change the color of ttk button in Tkinter?
- How to get the index of selected option in Tkinter Combobox?
- How to gray out (disable) a Tkinter Frame?
- How can I create a simple message box in Tkinter?
- How to disable (grey out) a checkbutton in Tkinter?
- Changing the appearance of a Scrollbar in Tkinter (using ttk styles)
- How can I identify when a Button is released in Tkinter?
- How can I determine the position of a Toplevel in Tkinter?
- How can I create a dropdown menu from a List in Tkinter?
Advertisements