首先,我是python和编码的新手
[我想用tkinter做一些非常简单的事情,当您按下一个按钮时,它会向您显示一个文本,就像在旧游戏中一样,一个接一个的字母一个字母一个字母,每个字符之间有一点延迟]]
我找不到在字符之间进行延迟的方法,我尝试使用循环[ after sleep
#MainFrame
root.title("Project")
root.geometry('400x400')
root.configure(bg="plum1")
#Frame
BlackBorder=Frame(root,width=400,height=300,bg='Black')
BlackBorder.place(x=0,y=80)
TxtFrame=Frame(BlackBorder,width=370,height=270,bg='lavender')
TxtFrame.place(x=15,y=15)
#Display
Cunter=Text(root,width=24,height=1,bg='lavender',font='Fixedsys')
Cunter.place(x=100,y=22)
Cunter.insert(END, str(len(LoList))+" Résultats Différents")
#defTxt
def LoMsg(self):
self=Text(TxtFrame,wrap='word',borderwidth=0,width=35,height=10,bg='lavender',font='Fixedsys')
self.place(x=50,y=100)
LoTxt=str(LovList[randrange(len(LovList))])
LoNum=0
while LoNum!=len(LoTxt):
self.insert(END,LoTxt[LoNum])
sleep(0.1)
LoNum+=1
#Button
buttonMain=Button(root,width=9,height=3,bg='thistle2',text="Try me",font='Fixedsys')
buttonMain.place(x=5,y=5)
#ButtonEvent
buttonMain.bind('<1>', LoMsg)
首先,我是python和编码的新手,我想使用tkinter做一些非常简单的事情,当您按下按钮时,它会向您显示一个文本,就像在旧游戏中一样,一个接一个的字母之间有点延迟...
after(ms, callback)
方法的用法以获得所需结果的示例(相应地在after方法中调整ms
:]