Advertisement
here2share

# Tk_pattern_of_8.py

Mar 24th, 2021
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # Tk_pattern_of_8.py
  2.  
  3. import random
  4. import time
  5.  
  6. try:
  7.     from Tkinter import *
  8. except:
  9.     from tkinter import *
  10.  
  11. root=Tk()
  12. root.title("Tk_pattern_of_8")
  13.  
  14. ww=640
  15. hh=640
  16.  
  17. canvas = Canvas(root, width=ww,height=hh)
  18. canvas.pack()
  19.  
  20. bricks = (
  21. (0,0,40,20),
  22. (0,20,40,40),
  23. (0,0,20,40),
  24. (20,0,40,40),
  25. (0,0,20,20),
  26. (0,20,20,40),
  27. (20,0,40,20),
  28. (20,20,40,40)
  29. )
  30.  
  31. while 1:
  32.     wait = time.time()+1
  33.     canvas.delete('all')
  34.     for x in range (0,ww,40):
  35.         for y in range(0,hh,40):
  36.             a,b,c,d = random.choice(bricks)
  37.             brick = a+x,b+y,c+x,d+y
  38.             canvas.create_rectangle(brick,fill='green',outline='green')
  39.     canvas.update()
  40.     while wait > time.time(): 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement