Need help with moving focus using Tkinter
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Thu Dec 5 09:17:42 EST 2002
On Thu, 2002-12-05 at 13:36, Richard Kuhns wrote:
> w.tk_focusNext(). When I try that, though, it quietly (and apparently
Not sure about tk_focusNext() I've never used it but something like this
may help:
from Tkinter import *
class EntryBoxes(Frame):
def __init__(self, parent, number=4):
Frame.__init__(self, parent)
self.entry_list = []
for n in range(number):
e=Entry(self)
e.pack(side="left")
e.bind("<KP_Enter>", self.press_enter)
self.entry_list.append(e)
def press_enter(self, event):
idx = self.entry_list.index(event.widget)
try:
self.entry_list[idx+1].focus_set()
except IndexError:
print "Last box!"
root=Tk()
fb = EntryBoxes(root)
fb.pack()
root.mainloop()
Regards
Martin
More information about the Python-list
mailing list