"""
pygame做的幻灯片显示5分钟编写完的程序
"""
import sys
import pygame
from glob import glob
__author__ = '李兴球'
__date__ = '2012/6/13 06:58'
__blog__ = 'www.lixingqiu.com'
images = [pygame.image.load(png) for png in glob("D:\\精武世界截图\\*.jpg")]
images_whs = [img.get_size() for img in images]
ims_amounts = len(images)
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("pygame做的幻灯片显示5分钟编写完的程序")
counter = 0
running = True
clock = pygame.time.Clock() # 建立时钟对象
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# 动一下按键就会显示一张不同的图像
if event.type == pygame.KEYDOWN: # 按任意键图片索引加1
counter += 1
counter %= ims_amounts
screen.fill((0,0,0))
w,h = images_whs[counter]
w,h = 400-w//2,300-h//2 # 确定渲染位置
screen.blit(images[counter], (w,h)) # 把图贴到screen上
pygame.display.flip() # 刷新屏幕显示
clock.tick(10) # fps为10
pygame.quit()
sys.exit()
-
- 2026 年 3 月
- 2026 年 2 月
- 2026 年 1 月
- 2025 年 12 月
- 2025 年 11 月
- 2025 年 10 月
- 2025 年 9 月
- 2025 年 6 月
- 2025 年 5 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2023 年 11 月
- 2023 年 9 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 2 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 8 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 5 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 7 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2018 年 3 月
- 2018 年 1 月
- 2017 年 9 月
- 2017 年 5 月
- 2017 年 1 月

