Tkinter: is there a has_focus method or property for a window?

James Stroud jstroud at ucla.edu
Tue Feb 7 15:17:03 EST 2006


Harlin Seritt wrote:
> I have two windows. One is a main config window. The other is an 'Add
> Setting' window. Both are using two different classes.
> 
> Once the Add Setting button is clicked on the Add Setting window, the
> setting is written to file. At that time the main config window should
> update its setting listing but it doesn't because it doesn't know it
> should.
> 
> I do notice that when the Add Setting window closes, the focus goes
> right back to the main config window. Is there a "has focus" event that
> can trigger a command for this window?
> 
> Also, if there is another way to get this done, I am open to
> suggestions.
> 
> Thanks,
> 
> Harlin Seritt
> 

You may want to use focus_set() to make sure a widget has focus, and 
event_generate() to send an event. I've noticed that events generated in 
parents will by processed by children that have focus. Both seem to be 
from the Widget interface.

James



More information about the Python-list mailing list