Python用Tkinter的Frame实现眼睛护士的倒计时黑色屏幕

import Tkinter,time
class MyFrame(Tkinter.Frame):
    def __init__(self):
        Tkinter.Frame.__init__(self)
        self.grid()
        self.canvas = Tkinter.Canvas(self, bg='black',width=self.winfo_screenwidth(),height=self.winfo_screenheight())
        self.canvas.pack()
        self.top = self.winfo_toplevel()
        
#       self.top.update_idletasks()
        self.top.overrideredirect(True)
        
        self.exitButton=Tkinter.Button(self,text='Exit',command=self.doExit)
        self.exitButton.pack()
        self.Label1=Tkinter.Label(self,text='Hello')
        self.Label1.pack()
        self.exitButton.config()
#       self.pack(fill='both')
        self.trickit(5)
        app.mainloop()
    def doExit(self):
        
        pather=self.winfo_parent()
        pather.quit()
        self.quit()
    def trickit(self,num):
        for j in range(num,0,-1):
            self.Label1["text"]=j
            self.update()
            time.sleep(1)
        self.doExit()

还没完工,倒计时没显示出来

 

改进版的:

import Tkinter,sys,time
class BeBig():
    root=Tkinter.Tk()
    Label1=Tkinter.Label(root,text=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
    def beBig(self):
        
        self.root.minsize(self.root.winfo_screenwidth(), self.root.winfo_screenheight())
        #self.root.geometry('300x200-100-100')
        self.root.config(bg='black')
        self.Label1.pack()
        topTitle=self.root.winfo_toplevel()
        topTitle.overrideredirect(True)
        self.trickit(5)
        self.root.mainloop()
    def trickit(self,num):
        for j in range(num,0,-1):
            self.Label1["text"]=j
            self.root.update()
            time.sleep(1)
            
        self.root.destroy()
beBig=BeBig()
beBig.beBig()

 

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页