focus_set() doesn't work
eric.brunel at pragmadev.com
Fri Oct 11 18:43:00 CEST 2002
Heiner Litz wrote:
> why does my new Toplevel widget:
(assuming Tkinter.Tk() here...)
> does not get the focus ?? *grr*
> the Top Line of the window remains grey instead of blue, like it should
You step in a bit of a mess here: different window managers (not to mention
different OSs) manage the input focus quite differently. So you'll have to
fiddle with focus_set, focus_force, tkraise, and so on to achieve the
result you want.
I tried your code on a Linux box with KDE 2 and it actually doesn't work.
However, using focus_force instead of focus_set did the trick. The
difference is subtle: focus_set gives the focus to the window if your
application already had the focus (note that it's not the case when you
issue interactive commands, since the application having the focus is then
the terminal running the Python interpreter), and focus_force gives the
focus to your window even if your application didn't have the focus, which
is considered evil in many cases (see Tk documentation @
HTH. Good luck!
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list