recently I’ve made a global function for my program (instead of many locals) that when pressing on a Listbox item -> it will put its text inside the entry widget, kind of “autocomplete” method (like in the image).
enter image description here
the problem that I’m facing is that now when I made the local “autocomplete” functions into one global one there’s delay by one iteration between the Listbox item that you’re clicking to the text that it will output to you in the Entry widget.
New fucntion:
@staticmethod
def fill_by_click(ui_element, event, listbox):
ui_element.delete(0, END)
ui_element.insert(END, listbox.get(ACTIVE))
def somefunction(self):
self.functions_list.bind('<<ListboxSelect>>', lambda e: self.fill_by_click(self.find_function, e, self.functions_list))
older ones:
def somefunction(self):
def insert_entry(term):
self.find_text_entry.delete(0, END)
self.find_text_entry.insert(END, popular_terms.get(ACTIVE))
popular_terms.bind('<<ListboxSelect>>', insert_entry)
it’s probably a combination of using lambda and giving widget as parameters but I don’t know how to resolve it.
I’ve tried to make some solution, but I’ve ended only with some dirty and chunky ones.