我已经关注这个问题好几天了,希望有人能对这个问题有所启发。我在windows 10下运行python 3.6.5,也遇到了同样的问题。
我试过几种不同的方法,但似乎微软是按照自己的方式来做的。我终于找到了一个有效的方法,但前提是你不隐藏根窗口:
import tkinter as tk
from tkinter import simpledialog
root = tk.Tk()
#root.withdraw() # This does not work if you hide the root window
root.update_idletasks()
answer1 = simpledialog.askstring("Test1","This one gets focus",parent=root)
root.update_idletasks()
answer2 = simpledialog.askstring("Test2","This one doesn't",parent=root)