24

I have a Combobox that I can currently type into. I want it to be so that the user can only choose a valid option from the drop down.

I can't seem to find a similar question online, and I don't see anything in the documentation that could help me out.

tristan957
  • 551
  • 2
  • 4
  • 14

1 Answers1

55

You can set the state to "readonly"

cb = ttk.Combobox(root, state="readonly", 
                  values=("one", "two", "three"))

From the python 3.6 documentation:

state: One of “normal”, “readonly”, or “disabled”. In the “readonly” state, the value may not be edited directly, and the user can only selection of the values from the dropdown list. In the “normal” state, the text field is directly editable. In the “disabled” state, no interaction is possible.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685