• 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()
  • 相关阅读:
    流形学习(Mainfold Learning)
    陈皓的博客
    背包九讲
    阮一峰的个人网站
    PyTorch教程【六】Transforms的使用
    PyCharm设置代码提示忽略大小写
    PyTorch教程【五】TensoBoard的使用
    pip 换源
    PyCharm常用快捷键
    JAVA基础篇—HashMap
  • 原文地址:https://www.cnblogs.com/wangjiyuan/p/pythonyanjing.html
Copyright © 2020-2023  润新知