Next / Previous / Contents / TCC Help System / NM Tech homepage

23. Focus: routing keyboard input

To say a widget has focus means that keyboard input is currently directed to that widget.

The order in which the tab key traverses the widgets is:

To sum up: to set up the focus traversal order of your widgets, create them in that order. Remove widgets from the traversal order by setting their takefocus options to 0, and for those whose default takefocus option is 0, set it to 1 if you want to add them to the order.

The above describes the default functioning of input focus in Tkinter. There is another, completely different way to handle it—let the focus go wherever the mouse goes. Under Section 19, “Universal widget methods”, refer to the .tk_focusFollowsMouse() method.

You can also add, change or delete the way any key on the keyboard functions inside any widget by using event bindings. See Section 24, “Events” for the details.