[Python] python开发的简单窗口界面的倒计时界面 →→→→→进入此内容的聊天室

来自 , 2019-05-08, 写在 Python, 查看 142 次.
URL http://www.code666.cn/view/6c7cd904
  1. # Countdown using Tkinter
  2. from Tkinter import *
  3. import time
  4. import tkMessageBox
  5.  
  6. class App:
  7.     def __init__(self,master):
  8.         frame = Frame(master)
  9.         frame.pack()
  10.         self.entryWidget = Entry(frame)
  11.         self.entryWidget["width"] = 15
  12.         self.entryWidget.pack(side=LEFT)
  13.         self.hi_there = Button(frame, text="Start", command=self.start)
  14.         self.hi_there.pack(side=LEFT)
  15.         self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
  16.         self.button.pack(side=LEFT)
  17.        
  18.     def start(self):
  19.         text = self.entryWidget.get().strip()
  20.         if text != "":
  21.             num = int(text)
  22.             self.countDown(num)
  23.        
  24.     def countDown(self,seconds):
  25.         lbl1.config(bg='yellow')
  26.         lbl1.config(height=3, font=('times', 20, 'bold'))
  27.         for k in range(seconds, 0, -1):
  28.             lbl1["text"] = k
  29.             root.update()
  30.             time.sleep(1)
  31.         lbl1.config(bg='red')
  32.         lbl1.config(fg='white')
  33.         lbl1["text"] = "Time up!"
  34.         tkMessageBox.showinfo("Time up!","Time up!")
  35.  
  36.     def GetSource():
  37.         get_window = Tkinter.Toplevel(root)
  38.         get_window.title('Source File?')
  39.         Tkinter.Entry(get_window, width=30,
  40.                       textvariable=source).pack()
  41.         Tkinter.Button(get_window, text="Change",
  42.                        command=lambda: update_specs()).pack()
  43.  
  44. root = Tk()
  45. root.title("Countdown")
  46. lbl1 = Label()
  47. lbl1.pack(fill=BOTH, expand=1)
  48. app = App(root)
  49. root.mainloop()
  50. #//python/7826

回复 "python开发的简单窗口界面的倒计时界面"

这儿你可以回复上面这条便签

captcha