Advertisement
here2share

# Tk_truchetish.py

Mar 26th, 2021
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. # Tk_truchetish.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_truchetish")
  13.  
  14. ww=1200
  15. hh=640
  16.  
  17. root.geometry("%dx%d+0+0"%(ww,hh))
  18. canvas = Canvas(root, width=ww,height=hh)
  19. canvas.pack()
  20.  
  21. while 1:
  22.     wait = time.time()+2
  23.     canvas.delete('all')
  24.     for y in range(0,hh,20):
  25.         for x in range (0,ww,20):
  26.             rnd = random.randint(0,2)
  27.             if rnd == 1:
  28.                 canvas.create_arc(x-10, y+10, x+10, y+30, start=0, style=ARC, width=2, extent=90)
  29.                 canvas.create_arc(x+10, y-10, x+30, y+10, start=180, style=ARC, width=2, extent=90)
  30.             elif rnd == 2:
  31.                 canvas.create_arc(x+10, y+10, x+30, y+30, start=90, style=ARC, width=2, extent=90)
  32.                 canvas.create_arc(x-10, y-10, x+10, y+10, start=270, style=ARC, width=2, extent=90)
  33.             else:
  34.                 canvas.create_line(x+10, y, x+10, y+20, width=2)
  35.                 canvas.create_line(x, y+10, x+20, y+10, width=2)
  36.     while wait > time.time():
  37.         canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement