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

  Рет қаралды 5,426

plus2net

plus2net

2 жыл бұрын

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
• Tkinter Autocomplete b...
Part II : Navigation and selection by arrows
• Tkinter Autocomplete u...
Part III : Different data sources, Pygsheets , MySQL database
• Tkinter Autocomplete o...
Part IV : Displaying all product attributes on selection
• Tkinter autocomplete r...
Part V: Using colour names as source
• Tkinter autocomplete t...
Source code is here
www.plus2net.com/python/tkint...
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
www.plus2net.com/python/tkint...
#AutoComplete #EntryAutocomplete #Tkinter #python #SelectOption #StringMatch #plus2net

Пікірлер: 15
@Onexification
@Onexification Жыл бұрын
this is the gem!
@philmillington5025
@philmillington5025 Жыл бұрын
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
@plus2net1
@plus2net1 Жыл бұрын
By using Insert(). Check the code here. You can also use listvariable to connect to a Tuple, www.plus2net.com/python/tkinter-listbox.php
@philmillington5025
@philmillington5025 Жыл бұрын
@@plus2net1 Thanks so much for your answer to my question it really makes the programme easier to use now we can see what’s on the list. Ps... I added a select button to create the variable to use in a function which goes to an Excel sheet as a criteria. Thank again and I look forward to learning more about Tinker with your tutorials and video’s. Regards Phil
@Suvank
@Suvank Жыл бұрын
❤️ 👍👍 Very Helpful. Sir can you make same thing on combobox only and combobox drop down as list
@plus2net1
@plus2net1 Жыл бұрын
I replied to other question pointing to this. There are some issues using Combobox , we will try again.
@Suvank
@Suvank Жыл бұрын
@@plus2net1 ok
@ajm0o
@ajm0o Жыл бұрын
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
@plus2net1
@plus2net1 Жыл бұрын
Hi, Yes can be added, All the options are displayed using one Listbox , so the properties of the listbox can be changed. Check here how to manage them . www.plus2net.com/python/tkinter-listbox.php Here properties like bg ( background colour ) and fg ( font color ) can be managed. Here while creating the listbox you can manage or by using config() you can update them. Hope this helps .
@ajm0o
@ajm0o Жыл бұрын
@@plus2net1 Unfortunately I tried to update it using the config class and unfortunately I get an error,, and at the same time I tried to add properties to the AutocompleteEntry class in this way.... self.data_entry = AutocompleteEntry (self.root , backaground="red" , forground="yellow" , border=0 ) Unfortunately, I tried to update it using the config class, and unfortunately I get an error,, at the same time I tried to add properties to the AutocompleteEntry class in this way .... Unfortunately, I get an error saying that the AutocompleteEntry class does not contain a backaground property and also does not contain a foreground property Sir, I need to change the color The background of the input field, as well as changing the edges of the input field so that I put this field inside the Label I hope you can solve this matter or write a small code and send it to me I will be very thankful to you
@plus2net1
@plus2net1 Жыл бұрын
@@ajm0o AutocompleteEntry is a different library and it has different properties, In the above tutorial two widgets are used , one is Entry box and other one is Listbox , so properties supported by these widgets can't work with different library widget. So try to use the properties supported by AutocompleteEntry library and work with it, Or change to Entry and Listbox as explained here. Hope this concept is clear.
@philmillington5025
@philmillington5025 Жыл бұрын
How do I get the result from the combo box to use as a varable, after I run the programe
@plus2net1
@plus2net1 Жыл бұрын
e1_str holds the value, so this can be internally used ( it is a sringvar so value is e1_str.get() ) or in other applications it can be accessed by from autocomplete import e1_str
@philmillington5025
@philmillington5025 Жыл бұрын
@@plus2net1 Thank you for taking the time to reply. Your solution works just fine and I can now get the string I was looking for by using the import method. Keep up the good work Regards Phil
Using tkinter with classes
28:23
Atlas
Рет қаралды 56 М.
Now THIS is entertainment! 🤣
00:59
America's Got Talent
Рет қаралды 38 МЛН
How to Pass Data between Multiple Windows in Tkinter
18:19
CodersLegacy
Рет қаралды 27 М.
Tkinter - Treeview Edit Cells Directly
45:45
JobinPy
Рет қаралды 20 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,5 МЛН
Style Tkinter Dropdown Menus in Python | OptionMenu Change Default Icon in Tkinter GUI
21:02
Fabio Musanni - Programming Channel
Рет қаралды 3,8 М.
Regular Expressions in Python
18:58
NeuralNine
Рет қаралды 75 М.
Python GUI listbox 📋
15:00
Bro Code
Рет қаралды 20 М.