Tkinter tkMessageBox disables Tkinter key bindings Tkinter tkMessageBox disables Tkinter key bindings tkinter tkinter

Tkinter tkMessageBox disables Tkinter key bindings


If I understand the problem, you get the bad behavior if you call tkMessageBox.showInfo() before calling mainloop. If that is so, I think this is a known bug in tkinter on windows.

The solution is simple: don't do that. If you need a dialog to show at the very start of your program, use after to schedule it to appear after mainloop has started, or call update before displaying the dialog.

For example:

root = Tk()root.after_idle(msg_test)root.mainloop()

The original bug was reported quite some time ago, and the tk bug database has moved once or twice so I'm having a hard time finding a link to the original issue. Here's one issue from 2000/2001 that mentions it: https://core.tcl.tk/tk/tktview?name=220431ffff (see the comments at the very bottom of the bug report).

The report claims it was fixed, but maybe it has shown up again, or maybe your version of tkinter is old enough to still have the bug.