none
Python Application in VS 2013 problem with Turtle Image RRS feed

  • Question

  • Here is my code.

    import turtle
    
    screen = turtle.Screen()
    
    # click the image icon in the top right of the code window to see
    # which images are available in this trinket
    image = "rocketship.gif"
    
    # add the shape first then set the turtle shape
    screen.addshape(image)
    turtle.shape(image)
    
    screen.bgcolor("lightblue")
    
    move_speed = 10
    turn_speed = 10
    
    # these defs control the movement of our "turtle"
    def forward():
      turtle.forward(move_speed)
    
    def backward():
      turtle.backward(move_speed)
    
    def left():
      turtle.left(turn_speed)
    
    def right():
      turtle.right(turn_speed)
    
    turtle.penup()
    turtle.speed(0)
    turtle.home()
    
    # now associate the defs from above with certain keyboard events
    screen.onkey(forward, "Up")
    screen.onkey(backward, "Down")
    screen.onkey(left, "Left")
    screen.onkey(right, "Right")
    screen.listen()

    And the error I get:

    I was told turtle can take .gif files. Then what is the problem?!

    Wednesday, June 28, 2017 7:32 PM

All replies

  • hey man,

    I was wondering did you by any chance find a solution for this problem?

    Also, I have this issue with turtle module in VS2019.

    It seems I can not import it, I mean import turtle isn't working at all

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File ".\turtle.py", line 2, in <module>
        screen-turtle.Screen()
    NameError: name 'screen' is not defined

    any idea?

    Thursday, May 23, 2019 8:47 AM