Terry J. Reedy <tjre...@udel.edu> added the comment:

With a truly minimal but reproducible example, I was able to understand and 
experiment. As is, widget creation is done without the event loop running.  
Displaying the message box shifts grabs the internal focus but also displays 
the unfocused tk window.  When the message box is dismissed and mainloop() is 
called, the root window is displayed apparently with focus but it is 
unresponsive to mouse click on the entry box, hence the entry box never gets 
focus and never gets keypresses.  This is a bug somewhere between tk and 
Windows window manager and focus management.

Adding after_idle delays the message box and entry creation until after the 
mainloop call, and clicking on the entry now works.  In this case, the 
(unfocused) root window is *not* displayed.


If the entry box is the proper default focused widget when the message box is 
dismissed, an even better fix, to me, is to bind the entry box and explicitly 
give it the focus.  According to the tk docs, focus_set should work.  But it 
does not on Windows (and I suspect that this is related to clicking not 
working).  focus_force does work.

Another solution is to add master.update() before createWidgets.  Clicking on 
then works.  Putting self.master.update() after the messagebox call does not 
work.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42867>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to