Python Turtle window with scrollbars

前端 未结 2 1411
时光取名叫无心
时光取名叫无心 2021-02-10 06:57

I am new to Python, and have written a simple program in Python 2.7 using turtle graphics, which draws a fractal shape. The problem I have is that the turtle window doesn\'t hav

2条回答
  •  眼角桃花
    2021-02-10 07:17

    Finally found some code at http://www.python-forum.de/viewtopic.php?f=1&t=24823&start=0 which provides a scrolled canvas for the turtle:

    import turtle
    import Tkinter as tkinter
    
    root = tkinter.Tk()
    root.geometry('500x500-5+40') #added by me
    cv = turtle.ScrolledCanvas(root, width=900, height=900)
    cv.pack()
    
    screen = turtle.TurtleScreen(cv)
    screen.screensize(2000,1500) #added by me
    t = turtle.RawTurtle(screen)
    t.hideturtle()
    t.circle(100)
    
    root.mainloop()
    

提交回复
热议问题