Advertisement
here2share

# Tk_truchet.py

Mar 26th, 2021
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. # Tk_truchet.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_truchet")
  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,1)
  27.             if rnd:
  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.             else:
  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.     while wait > time.time():
  34.         canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement