Creating an editable drop-down with Combobox
Drop-down lists are a succinct way of choosing a value by vertically displaying a list of values only when needed. This is also common to let users input another option that is not present in the list.
This functionality is combined in the ttk.Combobox
class, which takes the native look and feel of your platform drop-downs.
Getting ready
Our next application will consist of a simple drop-down entry with a couple of buttons to confirm the selection or clear its contents.
If one of the predefined values is selected or the Submit
button is clicked, the current Combobox value is printed in the standard output, as follows:

How to do it...
Our application creates a ttk.Combobox
instance during its initialization, passing a predefined sequence of values that can be selected in the drop-down list:
import tkinter as tk import tkinter.ttk as ttk class App(tk.Tk): def __init__(self): super().__init__() self.title("Ttk Combobox") colors...