import time, random, _thread from tkinter import * def hiirevajutus(event): global hx, hy hx=event.x hy=event.y def liigu(): global x, hx, y, hy while 1: x=(x*0.9+hx*0.1) y=(y*0.9+hy*0.1) ala.coords(ovaal, x, y, x+r, y+r) time.sleep(0.1) aken = Tk() ala = Canvas(aken, width=400, height=300, bg='white') ala.pack() x = 0 y = 10 r = 30 hx=100 hy=150 ovaal=ala.create_oval(x, y, x+r, y+r, fill="blue") ala.bind("", hiirevajutus) #ala.tag_bind(ovaal, "", hyppa) _thread.start_new_thread(liigu, ()) aken.mainloop()