Your post implied difficulty with understanding how to rotate triangles using complex numbers.
After reading your comment in reply to my answer I have edited my code sample to demonstrate a way to get the angle from keyboard input.
I have no experience with Tkinter so perhaps someone can help with a more state of the art approach.
Gleaned from Tkinter: Events and Bindings and The Tkinter Entry Widget
When you enter the keypress event handler, the Entry widget's text, retrieved with text.get(), doesn't include the latest keypress character.
The angle entered is in degrees and can be negative.
from Tkinter import *
import tkSimpleDialog as tks
import cmath,math
root = Tk()
c = Canvas(root,width=200, height=200)
c.pack()
# keypress event
def key(event):
text.focus_force()
ch=event.char
# handle backspace
if ch=='\x08':
if len(text.get())>1 :
entry_text=text.get()[:-1]
if entry_text=='-': entry_text='0'
else:
entry_text='0'
else:
entry_text=text.get()+ch
# we want an integer
try:
angle_degrees=int(entry_text)
cangle = cmath.exp(angle_degrees*1j*math.pi/180)
offset = complex(center[0], center[1])
newxy = []
for x, y in triangle:
v = cangle * (complex(x, y) - offset) + offset
newxy.append(v.real)
newxy.append(v.imag)
c.coords(polygon_item, *newxy)
except ValueError:
print "not integer"
text = Entry(root)
text.bind("<Key>", key)
text.pack()
text.focus_force()
# a triangle
triangle = [(50, 50), (150, 50), (150, 150)]
polygon_item = c.create_polygon(triangle)
center = 100, 100
mainloop()