How can I hide text using turtle write in python

Viewed 392

I know how to hide and unhide the circle/button, but I can't figure out how to do the same with the text "Click Me". I'm thinking that I may have to use clear, but the hope is that I could hide it and bring it back when I do the same with the button.

from turtle import Screen, Turtle

CURSOR_SIZE = 20
FONT_SIZE = 12
FONT = ('Arial', FONT_SIZE, 'bold')

def draw_onclick(x, y):
    turtle.dot(100, 'cyan')

button = Turtle()
button.hideturtle()
button.shape('circle')
button.fillcolor('red')
button.penup()
button.goto(150, 150)
button.write("Click me!", align='center', font=FONT)
button.sety(150 + CURSOR_SIZE + FONT_SIZE)
button.onclick(draw_onclick)
button.showturtle()

turtle = Turtle()
turtle.hideturtle()

screen = Screen()
screen.mainloop()

Thank you

1 Answers

For anyone how stumbles across this looking for the answer. The way I ended up doing it was to make two turtles. One for the "button" and one for the text. I would hide the button and button_text.clear() the the text. When I wanted to bring them back I would just unhide the turtle and .write() the text again.

Not was I was hoping for, but it works.

Related