Thanks for your help. This post sat around for so long without a response that I
worried people perceived it as a "dumb question".
| Elaine Jackson wrote:
| > I've got a Tk window with a large number of Text widgets, and I'd like to
have
| > the TAB key move focus from one Text widget to the next. Unfortunately I
can't
| > find the recipe. Can anybody help?
| >
| > Peace
|
| See methods tk_focusNext & tk_focusPrev in
|
http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.ht
m
|
| Here is an example:
|
| ----------------------------------------------------
| from Tkinter import *
|
| root = Tk()
|
| t1 = Text(root)
| t1.pack(side=TOP)
|
| t2 = Text(root)
| t2.pack(side=TOP)
|
| def focusNext(widget):
| widget.tk_focusNext().focus_set()
| return 'break'
|
| def focusPrev(widget):
| widget.tk_focusPrev().focus_set()
| return 'break'
|
| for t in (t1, t2):
| t.bind('<Tab>', lambda e, t=t: focusNext(t))
| t.bind('<Shift-Tab>', lambda e, t=t: focusPrev(t))
|
| t1.focus_set()
|
| root.mainloop()
| ----------------------------------------------------
|
| HTH
| --
| - Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
| PragmaDev : Real Time Software Development Tools -
http://www.pragmadev.com
|