Py学习  »  Python

打字机效果tkinter python

grozan programer • 3 年前 • 1447 次点击  

所以我想做一个游戏,我想让标题变成打字机效果,我知道打字机效果的代码,只是不知道如何实现它。 pitanje_菜单就是标签

ab=StringVar()
a=Label(textvariable=ab)
a.pack()
l=[]
for i in words:
    l.append(i)
    sleep(0.2)
    b=str(l)
    b=b.replace("[","")
    b=b.replace("]","")
    b=b.replace(", ","")
    b=b.replace(",","")
    b=b.replace("'","")
    b=b.replace("  ","")
    c=len(b)
    ab.set(f"{b[0:c-1]}{i}")
    a.update()


pitanje_menu = Label(win, text="the game", bg="black", fg="white", font= ('Open Sans', 100))
pitanje_menu.place(x= "770", y= "240", anchor=CENTER)
da_play = Button(win, text="play", bg="black", fg="white", font= ('Open Sans', 60), borderwidth=0, command=play)
da_play.place(x= "770", y= "490", anchor=CENTER)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/130361
 
1447 次点击  
文章 [ 1 ]  |  最新文章 3 年前