This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients christian.heimes, epaine, jmccabe, serhiy.storchaka, terry.reedy
Date 2021-01-10.23:20:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610320831.27.0.0607767456286.issue42867@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-01-10 23:20:31terry.reedysetrecipients: + terry.reedy, christian.heimes, serhiy.storchaka, epaine, jmccabe
2021-01-10 23:20:31terry.reedysetmessageid: <1610320831.27.0.0607767456286.issue42867@roundup.psfhosted.org>
2021-01-10 23:20:31terry.reedylinkissue42867 messages
2021-01-10 23:20:31terry.reedycreate