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

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

Written By plus2net on Sunday, Jan 02, 2022 | 10:07 PM

 
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 https://youtu.be/HulO1qiEn78 Part II : Navigation and selection by arrows https://youtu.be/QYeYi4LBpIU Part III : Different data sources, Pygsheets , MySQL database https://youtu.be/uKj4Py_At3w Part IV : Displaying all product attributes on selection https://youtu.be/c8DRdVDGV40 Part V: Using colour names as source https://youtu.be/RBKNM_uzGwg Source code is here https://www.plus2net.com/python/tkinter-autocomplete-source.php 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 https://www.plus2net.com/python/tkinter-autocomplete.php #AutoComplete #EntryAutocomplete #Tkinter #python #SelectOption #StringMatch #plus2net