好的,所以我只是想弄清楚为什么我的代码不像我想的那样工作.
我正在构建一个GUI,我希望在Label文本变量上显示文本.我已经创建了一个函数,在调用函数时更新Label,但当然这不是我的问题.
我的问题源于我试图实现"一次打印一个字母"类型的标签.虽然它打印到我想要的终端它,标签插件的整体功能后才更新已经完成(在视觉上它和上面一样打印整个字符串,而不是打印一次一个字母).
所以我错过了什么,我不明白什么?你们能帮助我吗?让我发布一些代码,以便你们可以看到我的错误.
我独立尝试了这两个,他们都给我带来了相同的结果,这不是我想要的.
def feeder(phrase):
"""Takes a string and displays the content like video game dialog."""
message = ""
for letter in phrase:
time.sleep(.15)
message += letter
information.set(message)
#print message
def feeder2(phrase):
"""Same as feeder, but trying out recursion"""
current.index += 1
if current.index <= len(phrase):
information.set(phrase[:current.index])
time.sleep(.1)
feeder2(current.status())
Run Code Online (Sandbox Code Playgroud)
如果我需要发布更多代码,我不是肯定的,所以你们可以更好地理解,但如果是这样的话,我会这样做.
这个功能使用了这两个功能
def get_info():
"""This function sets the textvariable information."""
#information.set(current)
feeder2(current.status())
Run Code Online (Sandbox Code Playgroud)
而这又用于此功能
def validate():
""" This function checks our guess and keeps track of our statistics …Run Code Online (Sandbox Code Playgroud)