How to rotate ellipse in tkinter canvas? How to rotate ellipse in tkinter canvas? tkinter tkinter

How to rotate ellipse in tkinter canvas?


The oval item of tkinter canvas is not rotatable as an oval.

If you look at the docs, like effbot.org, you'll see that some items are created with a first position arg (a single point, like text), some with a bbox arg (two points, like rectangle and oval), and some with coords (variable, two or more points, like line and polygon).

You can rotate the coords items by (1) calculating new coords and (2) updating the item with the new coords, using the coords() method.

For the rest of the items, you're out of luck, except for text which supports an angle attribute which you can set with itemconfig(item, angle=new_angle)

But all hope is not lost. You can convert a rectangle or oval into a polygon (by creating a new polygon to replace your old bbox item, and then you'll be able to rotate the new item. With rectangle, it's easy-peasy. With oval, it's much trickier, as you have to simulate the oval using many, many polygon coordinates for it to look good.


There are 2 ways that I know of 1) plot every point on the edge of the ellipse. There are pages on the web that show how to calculate all of the points 2) save as an image and use tkinter's PIL library to rotate the image.