Overriding the default tab behavior in Python Tkinter

I am writing a Python application using Tkinter to control my GUI.

There is an input text field in which I am trying to implement an autocomplete function that will be bound to the Tab key.

I linked the tab key to my input window, but when I press the tab key, the program tries to switch between the GUI elements.

How do I override this default behavior so that the GUI will only execute my specified command when a key is pressed?

+5
source share
1 answer

Return 'break' to the end of the event handler. He interrupts the spread of events.

 def my_tab_handler(event): ... # handle tab event return 'break' # interrupts event propagation to default handlers 
+11
source

All Articles