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

H

Harlin Seritt

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
 
J

James Stroud

Harlin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top