The Combobox widget

The ttk.Combobox argument is an Entry widget that adds a drop-down select menu. To populate the drop-down menu, simply pass in a values argument with a list of the strings, which the user can select.

You can execute the following code to create a Combobox widget:

combobox = ttk.Combobox(
    parent, textvariable=my_string_var,
    values=["Option 1", "Option 2", "Option 3"])

The preceding code will generate the following widget:

If you're used to HTML <SELECT> widgets or drop-down widgets in other toolkits, the ttk.Combobox widget may seem strange to you. It's really an Entry widget with a drop-down menu to select some preset strings. ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.