我如何去除python乌龟中的bgimage

发布于 2025-01-19 19:52:21 字数 214 浏览 0 评论 0原文

我类似地导入了BG图像

screen = turtle.Screen()


#reference image
screen.bgpic("image.png")

,然后我制作了图形,但是我想删除BG图像,因此只保留BGColor,如果i screen.clear.clear(),它可以清除我用Turtle绘制的一切。

I imported an bg image like so

screen = turtle.Screen()


#reference image
screen.bgpic("image.png")

then I made my graphic but I want to remove the bg image so only the bgcolor remains and if I screen.clear() it clears everything I drew with turtle.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱给你人给你 2025-01-26 19:52:21

根据文档,将'nopic'作为picname参数,它将删除当前图像:

bgpic(picname=None)
    Set background image or return name of current backgroundimage.
    
    Optional argument:
    picname -- a string, name of a gif-file or "nopic".
    
    If picname is a filename, set the corresponding image as background.
    If picname is "nopic", delete backgroundimage, if present.
    If picname is None, return the filename of the current backgroundimage.

'nopic' token在询问bgpic()如果没有背景图像集:

% python3
Python 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> turtle.bgpic()
'nopic'
>>> 

Per the documentation, pass 'nopic' as the picname argument and it will remove the current image:

bgpic(picname=None)
    Set background image or return name of current backgroundimage.
    
    Optional argument:
    picname -- a string, name of a gif-file or "nopic".
    
    If picname is a filename, set the corresponding image as background.
    If picname is "nopic", delete backgroundimage, if present.
    If picname is None, return the filename of the current backgroundimage.

The 'nopic' token is also returned when interrogating bgpic() if there is no background image set:

% python3
Python 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> turtle.bgpic()
'nopic'
>>> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文