【发布时间】:2021-01-31 17:13:46
【问题描述】:
当用户单击 QuitGame 按钮时,我一直在尝试显示带有“感谢您玩”等文字的标签。我试图通过在 MainMenuQuit 函数下包含这个标签(称为 QuitLabel)来做到这一点,以便在整个根被销毁之前,消息在界面上显示 3 秒。 但是,按下按钮时不会显示 2 个标签,尽管该功能的其余部分工作正常。 这是我的代码:
import time
import tkinter
root = Tk()
root.title("Menu")
root.geometry("1000x800")
root.configure(bg = "#339933")
root.resizable(True, True)
def MainMenuQuit():
Label(root, text = "", bg = "#339933").pack()
QuitLabel = Label(root, text = "Thank you for playing, come back soon!", fg = "blue", bg = "#339933").pack()
time.sleep(3)
root.destroy()
button1 = Button(root, text = "Quit Game", command = MainMenuQuit, width = "20", height = "3").pack()
root.mainloop()
【问题讨论】:
标签: python python-3.x user-interface tkinter python-3.7