Tkinter Countdown

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
bumsfeld bumsfeld is offline Offline Aug 20th, 2005, 11:56 am |
0
Just a colorful ten second countdown to New Year. Hope you can learn some code from it.
Quick reply to this message  
Python Syntax
  1. # ten second countdown to New Year using Tkinter
  2.  
  3. from Tkinter import *
  4. import time
  5.  
  6. def countDown():
  7. '''start countdown 10 seconds before new year starts'''
  8. lbl1.config(bg='yellow')
  9. lbl1.config(height=3, font=('times', 20, 'bold'))
  10. for k in range(10, 0, -1):
  11. lbl1["text"] = k
  12. root.update()
  13. time.sleep(1)
  14. lbl1.config(bg='red')
  15. lbl1.config(fg='white')
  16. lbl1["text"] = "Happy new year!"
  17.  
  18. root = Tk()
  19. root.title("Happy ...")
  20. lbl1 = Label()
  21. lbl1.pack(fill=BOTH, expand=1)
  22. countDown()
  23. root.mainloop()

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC