【发布时间】:2020-05-12 04:28:42
【问题描述】:
我正在编写一个生成单词然后用户可以输入答案的 Gui 游戏。我现在需要循环来防止这些单词弹出,只有在检查单词是否正确时才运行。
# Functions
def words():
global score
global timer
start = time.time()
while time.time() - start <= 60:
entry.focus_set() # Activate the entry box
word = random.choice(word_list[0])
word_label.config(text=word)
# Here should be code that makes it that a new word is only generated if the check word is run
root.update()
results(score)
def check_word(event, word, score):
global wrong
if entry.get().lower() == word.lower():
score += 1
entry.delete(0, 9999999)
else:
wrong += 1
【问题讨论】:
标签: python user-interface tkinter