Python在等待函数执行时使循环继续

Python在等待函数执行时使循环继续,python,asynchronous,tkinter,Python,Asynchronous,Tkinter,我试图在tkinter cavnas中创建点。已成功创建。但我想做的是在三秒钟后删除这一点。这也行。但我需要循环继续,而它等待3秒,我不知道如何实现。因为现在循环在等待createPoint时滞后3秒 def createPoint(self): .... point = self.canvas.create_oval(...) self.update() .... time.sleep(3) canvas.delete(point) se

我试图在tkinter cavnas中创建点。已成功创建。但我想做的是在三秒钟后删除这一点。这也行。但我需要循环继续,而它等待3秒,我不知道如何实现。因为现在循环在等待createPoint时滞后3秒

def createPoint(self):
    ....
    point = self.canvas.create_oval(...)
    self.update()
    ....
    time.sleep(3)
    canvas.delete(point)
    self.update()

def infiniteCycle(self):
    ....
    self.createPoint() 
    ....
使用
after()
代替
time.sleep()

def createPoint(self):
....
point=self.canvas.create_oval(…)
....
self.canvas.after(3000,self.canvas.delete,point)