当前位置:   article > 正文

Python+turtle实现一个图片播放器_python 播放图片

python 播放图片

我们可以利用Python+turtle实现一个简易的图片播放器,我们先看一下效果图

请添加图片描述

完整版代码:

['D:\照片\\' + i for i in os.listdir('D:\照片')]:os.listdir(‘这里写上你图片的保存路径’)
Screen().bgpic(pic_list[num]),加载图片至turtle的窗口上
Screen().update(),刷新窗口
ontimer(run, 1000),这里是间隔的时间,单位毫秒
import os
from turtle import *

pic_list = ['D:\照片\\' + i for i in os.listdir('D:\照片')]
num = 0
def run():
    global num
    if num > 4:
        num = 0
    Screen().bgpic(pic_list[num])
    Screen().update()
    num += 1
    ontimer(run, 1000)

run()
done()

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

非常简单的小代码,希望对你有所帮助

致力于办公自动化的小小程序员一枚#

都看到这了,关注+点赞+收藏=不迷路!!

如果你想知道更多关于Python办公自动化的知识各位大佬给个关注吧!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/788511
推荐阅读
相关标签
  

闽ICP备14008679号