我使用tkinter在python中创建一个文本冒险,因为它很容易使用图形(按钮等)
我想添加一个效果,使文本看起来像是被打印出来的。在
def displayNextPart():
for i in buttons:
i.destroy()
global curPart
for char in story[curPart]["Text"]:
slp(.05)
w.config(text=char)
sys.stdout.flush()
但窗口在完成前都会冻结,留给我的只有字符串的最后一个字符。在
有人能帮我吗?在
Tags:
你需要更新循环屏幕。最简单的方法是使用tkinter的
after
方法编写一个自重复函数。在这是一个有效的例子。这使用一个文本小部件,但是您可以很容易地更新标签小部件或画布文本项。在
time.sleep()
无法与Tkinter应用程序一起正常工作。使用after()
方法,如下例所示:相关问题 更多 >
编程相关推荐