tkinter and focus...

Matthew Dixon Cowles matt at mondoinfo.com
Mon May 28 14:30:33 EDT 2001


On 28 May 2001 11:07:31 GMT, Uwe Schmitt <schmitt at num.uni-sb.de>
wrote:

>focus_force() works fine. now i've got other problems:
>1) how can i change the order of widgets which are activated
>   by TAB ?
>2) my informationwindow (as described above) appears in the
>   left upper corner of the screen, but it should appear
>   near the main-window.

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

myWidget.bind("<Key-Tab>",self.tabInMyWidgetCB)

and then somewhere else in the class something like:

def tabInMyWidgetCB(self,event):
  self.otherWidget.focus_force()
  return "break"

You might want to do something similar with <Shift-Tab> too.

For specifying the location of a window, the geometry() method is
what you want. It's described in Fredrik Lundh's excellent An
Introduction to Tkinter at (wrapped for line length):

http://www.pythonware.com/library/tkinter/introduction/
  x9489-window-geometry-methods.htm

The whole document is very useful. I generally have a local copy
open when I'm doing Tkinter programming.

Regards,
Matt



More information about the Python-list mailing list