This answer https://stackoverflow.com/a/56653517/2323393 suggests that you can use the angle
attribute of the text object to rotate it.
For example
txt = canvas.create_text(250, 250, text='Hi')
canvas.itemconfig(txt, angle=90)
Or a more complete solution
import math
import tkinter as tk
def draw(angle, text):
x = math.cos(math.radians(angle)) * 50 + 250
y = math.sin(math.radians(angle)) * 50 + 250
obj = canvas.create_text(250, 250, text=text, fill="green")
canvas.itemconfig(obj, angle=-angle)
canvas.coords(obj, x, y)
return obj
root = tk.Tk()
canvas = tk.Canvas(root, width=500, height=500)
for i in range(0,360,60):
draw(i,"Hi")
canvas.pack()
root.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.