0

I'm looking for a simple way to rotate a shape in python, tkinter. The shape I'm rotating is a triangle (polygon) if it matters. Thanks in advance for all the help

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by vegaseat
0

cool thanks tonyjv that helps. Does anyone know a way to rotate anything other than polygons and lines... like say an image? again thanks in advance

0

The simplest way to rotate an image with the Tkinter GUI toolkit is to use the Python Image Library (PIL) rotate function.

Check:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
to download PIL versions for Python27 and Python32

A simple example ...

from PIL import Image

image = Image.open('Audi.jpg')

# rotate 270 degrees counter-clockwise
imRotate = image.rotate(270)
filename = "AudiRotated2.jpg"
imRotate.save(filename)

# a simple way to show the image file is to use module webbrowser
# which activates the default viewer associated with the image
# works with Windows and Linux
import webbrowser
webbrowser.open(filename)

Edited by vegaseat: code example

This question has already been answered. Start a new discussion instead.
Please be thoughtful and detailed and be sure to adhere to our posting rules.