Tkinter Autocomplete by using Entry and Listbox options from List using regular expression matching

preview_player
Показать описание
00:38 Different parts of the autocomplete script
01:20 Starting with a blank tkinter window
02:35 Declaring string variable e1_str
02:52 Adding Entry widget
05:04 Adding Listbox widget
09:08 Adding trace method of String variable to trigger get_data() function
10:00 get_data() function
11:49 Regular expression string match
15:10 Adding bind event to Listbox

Part I : Design , adding options and selection
Part II : Navigation and selection by arrows
Part III : Different data sources, Pygsheets , MySQL database
Part IV : Displaying all product attributes on selection
Part V: Using colour names as source

Source code is here

As the users will enter string in Entry box , we will offer matching options like Autocomplete by using one listbox and user can select any one option to fill the Entry box.
We will place the Listbox below the Entry widget and keep the ypad=0 so both widgets are placed one below the other.
We will change the Listbox background colour and active border colour same as window background colour to merge the layout of the Listbox with the window.
We will trigger and populate the listbox options by taking data from the source listbox , for this we will use one for loop to list all available options and use regular expression match method to get the strings ( options ) matching to the searched string.
Once the match() method returns true the element is added as option of the Listbox.
We can bind the Listbox selection to pass the selected option as input to Entry widget.
Source code is here

#AutoComplete #EntryAutocomplete #Tkinter #python #SelectOption #StringMatch #plus2net
Рекомендации по теме
Комментарии
Автор

Hi There, Is it possable to load the ListBox with the LIST when you run the prgrame so the user can see whats on the list. Reagrds Phil

philmillington
Автор

How do I get the result from the combo box to use as a varable, after I run the programe

philmillington
Автор

Peace be upon you, sir. Is it possible to add to the class AutocompleteEntry properties such as : background="red", foreground="yellow", border=0, ?
Please help I am trying to add these features and unfortunately I get an error

ajmo
Автор

❤️ 👍👍 Very Helpful. Sir can you make same thing on combobox only and combobox drop down as list

suvank
welcome to shbcf.ru