Need help with moving focus using Tkinter
Richard Kuhns
rjkuhns at geetel.net
Thu Dec 5 16:37:47 EST 2002
More information about the Python-list mailing list
Thu Dec 5 16:37:47 EST 2002
- Previous message (by thread): Need help with moving focus using Tkinter
- Next message (by thread): Threading/map question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Boy, you guys are good. I now have things working to my satisfaction, but there's still at least one thing I just don't understand, and I think that if I'm going to get good at this I probably should. On Thu, 5 Dec 2002 09:36:04 -0600 Jeff Epler <jepler at unpythonic.net> wrote: > Translation to Tkinter should be: > > t.bind_class("all", "<Key-ISO_Left_Tab>", "tkTabToWindow > [tk_focusPrev %W]") > > plus exception handling. Unfortunately, tkTabToWindow is considered a > Tk internal command. It does platform-dependent things (like selecting > the text of an entry when it gets focus) which .focus_set() doesn't do. Shift-Tab is "<Key-ISO_Left_Tab>" under FreeBSD 4.7 also. After I set it like you described it worked fine. > You should probably use > > t.bind_class("all", "<Key-ISO_Left_Tab>", > t.bind_class("all", "<Shift-Key-Tab>)) > > to copy the binding (if any) of Shift-Key-Tab to ISO_Left_Tab. t.bind_class("all", "<Shift-Key-Tab>") returns an empty string. > > > In Tk version 8.3, there is a new virtual binding <<PrevWindow>>, and > the Tk startup code makes to make <Key-ISO_Left_Tab> generate > <<PrevWindow>>. Tk 8.4 probably continues this tradition. You could > use this code sequence to create the virtual binding: > > t.event_add("<<PrevWindow>>", "<ISO_Left_Tab>") This works too. > I hope this information helps you out. It did; many thanks. However, could anyone please tell me why t.bind_class("all", "<Key-ISO_Left_Tab>", "tkTabToWindow [tk_focusPrev %W]") works and self.bind_all('<Return>', self.hitReturn) def hitReturn(self, event): print "+++Return was hit..." self.tk_focusNext().focus_set() doesn't? Eric Brunel brought it to my attention that tk_focusNext() returns the "next" window (if I could read I'd be dangerous), so it seems to me that the above code should work too. It doesn't, though -- it always sets the focus to the first widget. Thanks to Martin Franklin too for the suggestion to keep the widgets in a list; that would make it fairly simple to do extra processing on the final widget without having to worry about what it's called. Once again, thanks for the help -- it's better than any I've ever paid for. - Dick -- Richard Kuhns rjkkuhns at geetel.net
- Previous message (by thread): Need help with moving focus using Tkinter
- Next message (by thread): Threading/map question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list