How to get the coordinates of an object in a tkinter canvas?

前端 未结 1 1862
面向向阳花
面向向阳花 2021-02-18 19:21

I can\'t seem to figure out how to retrieve the x,y position of an oval created on a Tkinter canvas using Python via

c.create_oval(x0, y0, x1, y2)
<         


        
1条回答
  •  情深已故
    2021-02-18 19:21

    Assign the results of c.create_oval to x -- that's the "object ID" of the oval. Then,

    c.coords(x)
    

    gives you the (x1, y1, x2, y2) tuple of the oval's coordinates (you call coords with new coordinates following the x to move the oval).

    0 讨论(0)
提交回复
热议问题