Need help with moving focus using Tkinter

Eric Brunel eric.brunel at pragmadev.com
Thu Dec 5 10:00:38 EST 2002


Richard Kuhns wrote:

> I recently asked for help about creating a scrolling canvas to hold
> multiple frames, and was directed to Pmw.  That's worked out very nicely,
> and I really appreciate the pointer.  I've now hit another stumbling
> block, though, that I just can't find my way around.  I'm probably
> overlooking something very simple, too.
> 
> Here goes:  I'm using the scrolling canvas to hold an indefinite number of
> 1 line frames.  Each frame has 4 entry widgets.  All data entered will be
> numeric, so it would be very nice to be able to just use the keypad.
> Therefore I'd like the Enter to shift focus to the next widget on a line
> for the first 3 widgets, and then do some extra processing when pressed on
> the fourth widget.  It looks to me like I should be binding Enter to
> w.tk_focusNext(). 

Nope: according to Tk doc @ 
http://www.tcl.tk/man/tcl8.3/TkCmd/focusNext.htm (my _underscores_):
"""
tk_focusNext is a utility procedure used for keyboard traversal. It 
_returns_ the ``next'' window after window in focus order.
"""

So what you want to do is w.tk_focusNext().focus_set(), and it'll work like 
a charm...

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list