zoukankan      html  css  js  c++  java
  • 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()
  • 相关阅读:
    Unknown column '××' in 'where clause',出现这个问题,如何处理?
    mysql 安装失败 start service执行不下去
    2019第十届蓝桥杯国赛总结
    Win10中小娜无法搜索本地应用
    计蒜客 青出于蓝胜于蓝(dfs序+树状数组)
    计蒜客 棋子等级
    蓝桥杯 国王的烦恼(并查集)
    keras+theano+tensorflow+darknet
    caffe with anaconda
    matconvnet编译
  • 原文地址:https://www.cnblogs.com/wangjiyuan/p/pythonyanjing.html
Copyright © 2011-2022 走看看