Advertisement
here2share

# Tk_pattern_of_4.py

Mar 24th, 2021
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # Tk_pattern_of_4.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_4")
  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.  
  26. while 1:
  27.     wait = time.time()+1
  28.     canvas.delete('all')
  29.     for x in range (0,ww,40):
  30.         for y in range(0,hh,40):
  31.             a,b,c,d = random.choice(bricks)
  32.             brick = a+x,b+y,c+x,d+y
  33.             canvas.create_rectangle(brick,fill='green',outline='green')
  34.     canvas.update()
  35.     while wait > time.time(): 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement