在python中使用外部图像

2024-05-01 21:46:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我用海龟图形库做了一个简单的应用程序。你知道吗

我试过了。bgpic,但它好像不像我想的那样走。你知道吗

我将图像放在python源文件所在的同一个目录中,我这样做:

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

但这不会改变任何事情。当我运行它时,它只有白色的背景。你知道吗

我该怎么办?你知道吗


Tags: 图像目录应用程序png事情screen图形库背景
1条回答
网友
1楼 · 发布于 2024-05-01 21:46:07

图像必须是gif文件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.

图片.gif

enter image description here

import turtle

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

enter image description here

相关问题 更多 >