Using external image in python

463 Views Asked by At

I'm making simple application using turtle graphic library.

I tried to do .bgpic, But it seems doesn't walk as I wanted.

I putted the image at the same directory where python source file located, and I did like this:

screen = turtle.Screen()
screen.bgpic("picture.png")

but It doesn't changes anything. When I run it, it has just white background.

What should I do?

1

There are 1 best solutions below

3
On BEST ANSWER

Image must be gif-file, doc

turtle.bgpic(picname=None)

Parameters: picname – a string, name of a gif-file or "nopic", or None

Set background image or return name of current backgroundimage. If picname is a filename, set the corresponding image as background. If picname is "nopic", delete background image, if present. If picname is None, return the filename of the current backgroundimage.

picture.gif

enter image description here

import turtle

screen = turtle.Screen()
screen.bgpic("picture.gif")
turtle.done()

enter image description here