how to rotate text in python's turtle graphics

青春壹個敷衍的年華 提交于 2020-01-03 18:55:26

问题


I want to make diagrams with python's turtle (teaching purposes). The label "values" for the y-axis should be rotated.
Python's turtle has a method to write a string at current position:

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?


回答1:


It's not possible to write rotated text with turtle. See 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. 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.




回答2:


You CAN rotate text, but only in 8.6. Type:

pyturtle.rotate([Degrees of rotation])

Then you can do your text command. Hope this helped!



来源:https://stackoverflow.com/questions/4469125/how-to-rotate-text-in-pythons-turtle-graphics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!