Revision history  [back]

I suspect based on other more recent reports that the Tk window was coming up behind the IDE window, particularly if on macOS. If true, this may help:

import tkinter as tk
from tkinter import messagebox

# Set up Tk top-level to defeat macOS window order issues when debugging
import sys
if hasattr(sys, '_wing_debugger'):
  _root = tk.Tk()
  _root.withdraw()
  sw = _root.winfo_screenwidth()
  sh = _root.winfo_screenheight()
  _root.geometry(f'1x1+{sw // 2}+{sh // 3}')
  _root.deiconify()

print(messagebox.askyesno('title', 'question'))