幻灯片式显示字幕

幻灯片式显示字幕

"""
   幻灯片式显示字幕.py
   本程序会随机显示自我介绍的文字在海龟图屏幕上。
"""
import time
import random
import turtle

introduces = ['嗨!','我叫李兴球',
             '我喜欢用Python编程',
             '我要写非常棒的代码',
             '让人们一看就能明白',
             '我家住在江西萍乡市',
             '欢迎你到萍乡来!']

screen = turtle.getscreen()
screen.bgcolor('black')

w = screen.window_width()
h = screen.window_height()

turtle.speed(0)
turtle.penup()
turtle.color('cyan')
turtle.hideturtle()

ft = ('黑体',24,'italic')
for intro in introduces:
    x = random.randint(-w//2+100,w//2-100)
    y = random.randint(-h//2+100,h//2-100)
    turtle.goto(x,y)
    turtle.clear()
    turtle.write(intro,align='center',font=ft)
    time.sleep(2)
    

李兴球

李兴球的博客是Python创意编程原创博客