如何在Python的Turtle图形中旋转文字
-
11-10-2019 - |
题
我想用python的乌龟制作图表(教学目的)。 Y轴的标签“值”应旋转。
python的乌龟有一种在当前位置上编写字符串的方法:
from turtle import *
left(90) # does not help
write("values", font=('Arial', 12, 'normal'))
hideturtle()
mainloop()
“值”仍然是水平的。
如何用Python的乌龟旋转文字?
解决方案
不可能用乌龟写旋转的文字。看 http://www.gossamer-threads.com/lists/python/bugs/879806:
Turtle建立在TK的顶部,该TK目前为8.5版 - 这无法旋转文本。当TK版本8.6到达时,应该能够编写旋转的文本(请参阅 http://mail.python.org/pipermail/tkinter-discuss/2010-november/002490.html)和Turtle.py可以更新以利用它。
其他提示
您可以旋转文本,但只能在8.6中旋转。类型:
pyturtle.rotate([Degrees of rotation])
然后,您可以执行文本命令。希望这有所帮助!
不隶属于 StackOverflow