简体   繁体   English

如何在python的乌龟图形中旋转文本

[英]how to rotate text in python's turtle graphics

I want to make diagrams with python's turtle (teaching purposes). 我想用python的乌龟制作图表(教学目的)。 The label "values" for the y-axis should be rotated. 应旋转y轴的标签“值”。
Python's turtle has a method to write a string at current position: Python的乌龟有一种在当前位置写一个字符串的方法:

from turtle import *
left(90) # does not help
write("values", font=('Arial', 12, 'normal'))
hideturtle()
mainloop()

"values" is still horizontal. “价值”仍然是水平的。

How can I rotate text with python's turtle? 如何用python的乌龟旋转文本?

It's not possible to write rotated text with turtle. 用乌龟写旋转的文字是不可能的。 See http://www.gossamer-threads.com/lists/python/bugs/879806 : http://www.gossamer-threads.com/lists/python/bugs/879806

Turtle is built on top of Tk, which is currently at version 8.5 - this has no ability to rotate text. Turtle建立在Tk之上,目前版本为8.5 - 它无法旋转文本。 When Tk version 8.6 arrives it should be able to write rotated text (see http://mail.python.org/pipermail/tkinter-discuss/2010-November/002490.html ) and turtle.py could be updated to take advantage of it. 当Tk版本8.6到来时它应该能够写入旋转的文本(参见http://mail.python.org/pipermail/tkinter-discuss/2010-November/002490.html )并且可以更新turtle.py以利用它。

You CAN rotate text, but only in 8.6. 您可以旋转文本,但仅限于8.6。 Type: 类型:

pyturtle.rotate([Degrees of rotation])

Then you can do your text command. 然后你可以做你的文本命令。 Hope this helped! 希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM