here2share

# Tk_Happy_Holidays.py

Oct 27th, 2021 (edited)
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # Tk_Happy_Holidays.py
  2.  
  3. import Tkinter
  4. import random
  5.  
  6. import datetime
  7. year = str(datetime.datetime.now().year)
  8.  
  9. root = Tkinter.Tk()
  10. w = Tkinter.Canvas(root, width=400, height=300, background="#72DEE1")
  11.  
  12. flake = [];
  13. moves = []
  14. for i in range(60):
  15.  flake.append(w.create_text(random.randrange(-100,420),random.randrange(-20,300),text="*",fill="#ffffff",font="Times 40"))
  16.  moves.append([0.5 + random.random()/10,1.0 + random.random()])
  17.  
  18. w.create_text(200,140,text="HAPPY HOLIDAYS "+year,font="Arial 26 bold",fill="#B00000")
  19. w.create_text(200,180,text="From The Many Who Appreciate You !!!",font="Arial 15 bold",fill="#1DB50B")
  20. w.pack()
  21.  
  22.  
  23. while 1:
  24.     for i in range(len(flake)):
  25.         p = w.coords(flake[i])
  26.         p[0]+=moves[i][0]
  27.         p[1]+=moves[i][1]
  28.         w.coords(flake[i],p[0],p[1])
  29.         if(p[1]>310):
  30.             w.coords(flake[i],random.randrange(-100,400),-20)
  31.         root.update_idletasks() # redraw
  32.         root.update() # process events
  33.  
  34.  
  35.  
Add Comment
Please, Sign In to add comment