python使用simpledialog出现RuntimeError: main thread is not in main loop的问题

最近在学python,先上代码:

import threading
import tkinter.simpledialog

def showDialog(evt):
    dlg = tkinter.simpledialog.SimpleDialog(root,text='Test!', buttons=['OK'])
    dlg.go()

def test():
    threading.Thread(target=root.event_generate, args=('<<showDialog>>',)).start()

root = tkinter.Tk()
root.bind('<<showDialog>>',showDialog)
tkinter.Button(text = 'showDialog',command = test).pack()
root.mainloop()

使用的是python3.4,第一次点击showDialog按钮一切正常,但是之后再点就出现RuntimeError: main thread is not in main loop这个错误,请教一下这个问题的原因和解决办法。

如果你的主线程是mainloop,建议把import tkinter换成from mttkinter import mtTkinter as tkinter
如果是while True:update就没办法了