944,110 Members | Top Members by Rank

Ad:
  • Python Code Snippet
  • Views: 3809
  • Python RSS
0

Tkinter Countdown

by on Aug 20th, 2005
Just a colorful ten second countdown to New Year. Hope you can learn some code from it.
Python Code Snippet (Toggle Plain Text)
  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:
Previous Thread in Python Forum Timeline: Zip and Unzip Data (Python)
Next Thread in Python Forum Timeline: Steps in learning Python





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC