import tkinter as tk
import time
import threading
def the_thread():
time.sleep(1)
def startthread():
th.start()
window=tk.Tk()
s=tk.Button(window,text="确定",command=startthread).pack()
th=threading.Thread(target=the_thread)
window.mainloop()
点击按钮两次就会提示threads can only be started once
题主创建了全局变量th,并在第一次点击按钮时启动了全局变量th对应的线程,该线程1秒钟后结束。一个线程启动后,无论结束与否,都不能再次启动,否则就会出错。如果楼主想每次点击按钮就启动一个线程,则应该把创建线程的那一句放到startthread函数中。