Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_truchetish_2.py
- import random
- import time
- try:
- from Tkinter import *
- except:
- from tkinter import *
- root=Tk()
- root.title("Tk_truchetish_2")
- ww=1200
- hh=640
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww,height=hh)
- canvas.pack()
- while 1:
- wait = time.time()+2
- canvas.delete('all')
- for y in range(0,hh,20):
- for x in range (0,ww,20):
- rnd = random.choice([1,3])
- if rnd == 1:
- canvas.create_line(x, y+10, x+10, y, width=2)
- canvas.create_line(x+10, y+20, x+20, y+10, width=2)
- elif rnd == 2:
- canvas.create_line(x, y+10, x+10, y+20, width=2)
- canvas.create_line(x+10, y, x+20, y+10, width=2)
- elif rnd == 3:
- canvas.create_line(x+10, y, x+10, y+20, width=2)
- elif rnd == 4:
- canvas.create_line(x, y+10, x+20, y+10, width=2)
- else:
- canvas.create_line(x+10, y, x+10, y+20, width=2)
- canvas.create_line(x, y+10, x+20, y+10, width=2)
- while wait > time.time():
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement