Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding default tab behaviour in Python Tkinter

I am writing an application in Python using Tkinter to manage my GUI.

There is a text entry box on which I am trying to implement an autocompletion function which will bind to the Tab key.

I have bound the tab key to my entry box, but when I press tab, the program attempts to cycle between GUI elements.

How do I override this default behavior so that the GUI will only carry out my specified command on the key press?

like image 621
TartanLlama Avatar asked Nov 03 '10 19:11

TartanLlama


1 Answers

Return 'break' at the end of your event handler. It interrupts event propagation.

def my_tab_handler(event):
    ... # handle tab event
    return 'break' # interrupts event propagation to default handlers
like image 94
Steven Rumbalski Avatar answered Nov 15 '22 08:11

Steven Rumbalski