Turtle graphics - How do I control when the window closes?

前端 未结 5 1653
刺人心
刺人心 2020-12-14 01:01

I have a small python script which draws some turtle graphics. When my script has finished running, the turtle screen automatically closes, so to be able to see the graphics

5条回答
  •  没有蜡笔的小新
    2020-12-14 01:27

    simply use the mainloop() function imported from turtle's module itself!.

    import turtle
    
    
    #Draw a square
    for i in range(4):
        turtle.forward(200)
        turtle.left(90)
    
    
    #calling for the mainloop()
    turtle.mainloop()
    

提交回复
热议问题