Turtle graphics - How do I control when the window closes?
import turtle
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
# etc.
turtle.getscreen()._root.mainloop() # <-- run the Tkinter main loop
(edit: turtle.done()
as suggested by hua below is less ugly.)
Just use turtle.done()
or turtle.Screen().exitonclick()
as a last command of your turtle program.