python turtle绘画 有没有办法加载一幅画作为背景?

lkf181 2018-08-04 01:42:24
我想要的背景比较复杂,如果都用代码绘制有点太复杂了......... 比如:我想在世界地图上根据实时数据绘制绘制热点等
...全文
2077 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lkf181 2018-08-16
  • 打赏
  • 举报
回复
引用 1 楼 wangrunhuan 的回复:

turtle.bgpic(r'res/bg.png') #这样设置。


下面是方法的介绍:
def bgpic(self, 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.

Example (for a TurtleScreen instance named screen):
>>> screen.bgpic()
'nopic'
>>> screen.bgpic("landscape.gif")
>>> screen.bgpic()
'landscape.gif'
"""
if picname is None:
return self._bgpicname
if picname not in self._bgpics:
self._bgpics[picname] = self._image(picname)
self._setbgpic(self._bgpic, self._bgpics[picname])
self._bgpicname = picname

谢谢,不过加载过来图片会缩小,又是个麻烦事儿........
wangzhensuo 2018-08-12
  • 打赏
  • 举报
回复

turtle.bgpic(r'res/bg.png') #这样设置。


下面是方法的介绍:
def bgpic(self, 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.

Example (for a TurtleScreen instance named screen):
>>> screen.bgpic()
'nopic'
>>> screen.bgpic("landscape.gif")
>>> screen.bgpic()
'landscape.gif'
"""
if picname is None:
return self._bgpicname
if picname not in self._bgpics:
self._bgpics[picname] = self._image(picname)
self._setbgpic(self._bgpic, self._bgpics[picname])
self._bgpicname = picname

3,423

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧