tkinter and focus...

Isaac To Kar Keung kkto at csis.hku.hk
Mon May 28 21:44:12 EDT 2001


>>>>> "Matthew" == Matthew Dixon Cowles <matt at mondoinfo.com> writes:

    Matthew> Uwe, The best way I've found to change the tab order is to bind
    Matthew> the tab key event of a widget to a routine that changes the
    Matthew> focus with focus_set() or focus_force(). You might have a line
    Matthew> like this in the routine that creates your widgets:

Tab traversal is done by using the tk_focusNext and tk_focusPrev to find the
next and previous widget that can take the focus.  According to the man page
of tk_focusNext:

  The focus order is determined by the stack- ing order of windows and the
  structure of the window hierarchy.  Among siblings, the focus order is the
  same as the stacking order, with the lowest window being first.  If a
  window has children, the window is visited first, followed by its children
  (recursively), followed by its next sib- ling.

So basically, what you should really do is to change the stacking order of
the widgets, by using tkraise and lower.

Regards,
Isaac.



More information about the Python-list mailing list