[英]Trying to rotate the text by 90
I am using Tkinter and CanvasPlus library to rotate the text by 90 degrees but I am not able to rotate.我正在使用 Tkinter 和CanvasPlus库将文本旋转 90 度,但我无法旋转。 This is the code I am trying这是我正在尝试的代码
self.circle = self.canvas.create_circle(0, 0, self.circle_radius, fill=self.bg_color,
outline="green", width=3)
self.label_ready_for_cooking = self.canvas.create_label(0, 0, font=("Arial", 28),
fg="white", bg=self.bg_color,
text="READY\nFOR", anchor="be")
self.canvas.rotate(self.label_ready_for_cooking, 10, 10, 90, unit="deg")
The image is showing but I am not able to rotate the image.图像正在显示,但我无法旋转图像。 How can I do this?我怎样才能做到这一点?
With reference to the GitHub Wiki of this library参考本库的GitHub Wiki
CanvasPlus.rotate() There's no easy way to rotate something in tkinter. CanvasPlus.rotate()在 tkinter 中旋转东西没有简单的方法。 Usually, there's a lot of math and trig that is put into it.通常,其中包含很多数学和三角函数。 This method uses complex numbers to rotate a polygon clockwise in radians or degrees.此方法使用复数以弧度或度数顺时针旋转多边形。
Basically all the transformations are only applicable to polygons and not any of theWidget Windows .基本上所有的转换都只适用于多边形而不是任何小部件 Windows 。
UPDATE更新
You could achieve what you are looking for by using the angle
parameter of create_text
in the default Canvas
widget of tkinter
.您可以通过在 tkinter 的默认Canvas
小部件中使用create_text
的angle
参数来实现您正在寻找的tkinter
。
Try this尝试这个
from tkinter import *
root=Tk()
canvas=Canvas()
canvas.pack()
canvas.create_text(100,100,text='Rotated Text',angle=90)
root.mainloop()
Note that angle option is available in tk 8.6.x.请注意,角度选项在 tk 8.6.x 中可用。 @ acw1668 @ acw1668
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.