0

I am binding my main textinput event with a function to update a listbox with the words for auto completion. The function is getting the input from the textinput, and then using that value it is finding words for autocompletion. However, there is one problem. Getting the string includes each string except the last letter. This is because the default function (adding the letter to the end) is not executing before my custom event function. How can I execute the default first?

def update_words(event: tkinter.Event):
    global words_listbox
    instance = event.widget
    starting_string = instance.get("0.0", customtkinter.END).split()[-1]
    words_listbox.get_words(start)
  • I don't know of any way to get the default handler to run first, but you can do `widget.after(1, actually_update_words)` to run another function after all handlers have finished. – jasonharper Jun 24 '23 at 18:27
  • Just a function does not reproduce the issue, it is better to provide a [mre]. – acw1668 Jun 24 '23 at 18:42
  • @jasonharper: there are ways. Tk’s event handling is very flexible. – Bryan Oakley Jun 24 '23 at 20:42
  • Well, I still don't know how to run the default function first, but in my case, it worked by simply changing the event from "Key" to "KeyRelease" – PythonBeginner Jul 02 '23 at 05:33

0 Answers0