【发布时间】:2023-04-06 08:18:01
【问题描述】:
我遇到的问题是,我尝试使用 time.sleep(3) 将第一个功能(StartUpScr)小部件在屏幕上保留 3 秒,然后删除所有放置在屏幕上的小部件,然后继续放置下一个功能(MenuScr)小部件。我已经成功地使用 destroy() 删除第一个小部件并用第二个小部件替换它们,但是由于某种原因,在函数和主程序的任何地方输入 time.sleep(3) 时,而不是第一个小部件留下3 秒,然后被替换它会延迟程序的启动,产生一个空白屏幕,然后快速闪过第一个屏幕到第二个屏幕。
from tkinter import *
import tkinter
import time
window = tkinter.Tk()
window.title("BINARY-SUMS!!!")
window.geometry("1000x800")
window.wm_iconbitmap('flower3.ico')
window.configure(background='lavender')
def StartUpScr():
StartUpScr = tkinter.Label(window, text="FIRST-SCREEN!!!",fg = "Aqua",bg = "Lavender",font = ("Adobe Gothic Std B", 90, "bold" )).pack()
StartUpLabel = tkinter.Label(window, text="Developed by Robert Bibb 2016",bg = "Lavender",font = ("Calibri Light (Headings)", 10, "italic" ))
StartUpLabel.pack()
StartUpLabel.place(x = 400, y = 775)
def MenuScr():
StartUpScr = tkinter.Label(window, text="SECOND-SCREEN!!!",fg = "green",bg = "Lavender",font = ("Adobe Gothic Std B", 85, "bold" ))
StartUpScr.pack()
if __name__ == "__main__":
StartUpScr()
time.sleep(3)
for widget in window.winfo_children():
widget.destroy()
MenuScr()
【问题讨论】:
-
我会为函数和变量使用不同的名称。
-
您好 Robb,请您向以下回答者提供反馈,好吗?他们看起来都在尽力帮助你。