Bug report
simpledialog.SimpleDialog.go() and Dialog use _temp_grab_focus(), which calls grab_current() and focus_get() to restore the previous grab and focus afterwards. Both convert the Tcl window name with _nametowidget(), which raises KeyError for windows which were not created by tkinter, such as the native message box (.__tk__messagebox) or Tk's file dialogs on X11.
import tkinter
from tkinter import messagebox, simpledialog
root = tkinter.Tk()
root.after(300, lambda: simpledialog.SimpleDialog(root, text='hi', buttons=['OK']).go())
messagebox.showinfo('t', 'm', parent=root)
KeyError: '__tk__messagebox'
This happens in IDLE when a dialog is opened from an event delivered while a message box is shown (#153481). Regression from #151848 (3.16).
Linked PRs
Bug report
simpledialog.SimpleDialog.go()andDialoguse_temp_grab_focus(), which callsgrab_current()andfocus_get()to restore the previous grab and focus afterwards. Both convert the Tcl window name with_nametowidget(), which raisesKeyErrorfor windows which were not created by tkinter, such as the native message box (.__tk__messagebox) or Tk's file dialogs on X11.This happens in IDLE when a dialog is opened from an event delivered while a message box is shown (#153481). Regression from #151848 (3.16).
Linked PRs