Python:用海龟制作背景图像

Python:用海龟制作背景图像,python,background-image,turtle-graphics,Python,Background Image,Turtle Graphics,我正试图在我的海龟世界中插入一个.gif文件作为背景图像,让一只单独的海龟继续旅行,但我无法让它工作。我是python新手,任何帮助都会很好 以下是当前代码: from turtle import * from Tkinter import * def test(): turtle.bgpic("warehouse1.gif") fd(100) goto(50, 100) 来自turtle import*的使turtle模块中的所有名称都可用,因此您可以在本例中使用

我正试图在我的海龟世界中插入一个.gif文件作为背景图像,让一只单独的海龟继续旅行,但我无法让它工作。我是python新手,任何帮助都会很好

以下是当前代码:

from turtle import * 
from Tkinter import *

def test():
    turtle.bgpic("warehouse1.gif")
    fd(100)
    goto(50, 100)

来自turtle import*的
使
turtle
模块中的所有名称都可用,因此您可以在本例中使用bare
bgpic()

#!/usr/bin/env python
from turtle import *

def test():
    speed(1) # set the slowest speed to see the turtle movements
    bgpic('warehouse1.gif')
    fd(100)
    goto(50, 100)
    mainloop()

test()

注意:一般来说,您不应该在Python交互式shell之外使用通配符导入(
*
)。请参阅。

添加您遇到问题的代码,或者添加您收到的任何错误消息,都会让这里的人更容易帮助您。创建一个完整的最小示例,再现错误和您的问题,包括代码和您收到的错误,例如,运行
import-turtle;.bgpic('your.gif')
,并报告任何错误。