AutoComplete Combobox Widget in Tkinter

In this tutorial we will discuss how to implement the AutoComplete (also known as autofill) feature within the Tkinter Combobox Widget. The native Tkinter implementation of the Entry widget does not directly support such a feature, hence we must turn to third party solutions, or develop our own.

Luckily, there is a convenient and easy to use third-party module we can use for this purpose. The name of this module is ttkwidgets, and can be installed using the following command.

pip install ttkwidgets

AutoComplete Combobox Widget

To use the AutoComplete Combobox Widget, we will first make the required import from the autocomplete module in ttkwidgets.

Python
from ttkwidgets.autocomplete import AutocompleteCombobox

We will then define the list of options to be presented in our combobox.

Python
options = ["Apple", "Banana", "Cherry", "Date", "Grapes", "Kiwi", "Mango", "Orange", "Peach", "Pear"]

We then initialize the AutoComplete Combobox using this list of options, in the completevalues parameter.

Python
combobox = AutocompleteCombobox(root, completevalues=options)

Other than this one difference (completevalues parameter), it functions exactly like a regular Tkinter Combobox. Here is the full code.

Python
import tkinter as tk
from ttkwidgets.autocomplete import AutocompleteCombobox

options = ["Apple", "Banana", "Cherry", "Date", "Grapes", "Kiwi", "Mango", "Orange", "Peach", "Pear"]

# Create the main window
root = tk.Tk()
combobox = AutocompleteCombobox(root, completevalues=options)
combobox.pack(padx=50, pady=50)

# Run the Tkinter event loop
root.mainloop()

Which produces the following output. As we typed the letter “O”, the suggestion “Orange” appeared within the combobox. Pressing enter, or the right arrow key on your keyboard will make this suggestion permanent in your combobox.

AutoComplete Combobox Widget in Tkinter

There is also an AutoComplete Entry widget available within this module. Follow the link to learn more.


This marks the end of the AutoComplete Combobox Widget in Tkinter Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.

Leave a Comment