def work():
tk = Tk()
tk.update()
print(tk.winfo_screenwidth(),tk.winfo_screenheight())
tk.geometry('{}x{}'.format(tk.winfo_screenwidth(),tk.winfo_screenheight()))
tk.attributes("-topmost", True)
tk.attributes("-fullscreen",True)
tk.mainloop()
timeLabel = Label(tk,text = str(0) + ':' + str(5))
timeLabel.pack(fill = BOTH,expand = True)
for i in range(5):
time.sleep(1)
timeLabel.config(text = str(0) + ':' + str(5 - i))
tk.destroy()
运行的时候timeLable并没有显示出来
请问如何显示timeLable?并且还要显示在中间
mainloop后面的都执行不到,上面都是无限循环了,后面的你不关了窗口根本不执行
from tkinter import *
def countdown(n):
n = n -1
timeLabel["text"] = str(n).zfill(2)
if n == 0:
timeLabel["text"] = "火箭发射"
return None
timeLabel.after(1000,countdown,n)
tk = Tk()
timeLabel = Label(tk,text = "05")
timeLabel.pack(expand =1,fill="both")
timeLabel.after(1000,countdown,5)
tk.mainloop()