新编码并尝试制作一个得分板程序,当目标得分时,我希望文本颜色改变,然后在2秒后恢复原始颜色。我添加了2秒的睡眠功能,但它似乎延迟了整个过程而不是颜色变化。
# def actions that will take place when away team scores
def a_goal():
global awayscore
awayscore += 1
Label(main, text=awayscore, font='TkFixedFont 50 bold', fg='red', background= 'black').place(x=100, y=100)
time.sleep(2)
Label(main, text=awayscore, font='TkFixedFont 50 bold', fg='orange', background= 'black').place(x=100, y=100)