Reputation: 11
I am writing program using python turtle. To write text in turtle window, I am using this code:
def write_text(center_x,center_y,text): # Write text on the Screen
board.speed(1)
print("I am here")
board.penup()
board.goto(center_x,center_y)
board.write(text)
But this code is not writing anything in turtle window. Can anyone help me?
Upvotes: 1
Views: 1956
Reputation: 41905
Your write_text()
funtion is basically fine. I'd look for other reasons why you're not seeing the text. E.g. is your pen color the same as the background color? Is your screen DPI too dense to see the tiny font that turtle uses by default?
Try this simplification of your function along with some code to call it:
from turtle import Screen, Turtle
FONT = ('Arial', 16, 'normal')
def write_text(center_x, center_y, text):
''' Write text on the Screen '''
board.penup()
board.goto(center_x, center_y)
board.write(text, font=FONT)
board = Turtle()
write_text(100, 100, "You are here.")
screen = Screen()
screen.exitonclick()
Do you still not get any writing in your turtle window?
Upvotes: 1