Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_after.py
- from Tkinter import *
- import random
- root = Tk()
- h = 360
- w = 640
- root.geometry('%dx%d+10+10'%(w,h))
- objs = []
- colors='red orange yellow green cyan blue purple goldenrod khaki grey black'.split()
- c=colors[:]
- def removeobjs():
- if len(objs) > 0:
- canvas.delete(objs.pop(random.randrange(len(objs))))
- #
- def randomobjs():
- w2 = (random.randrange(200))+10
- h2 = (random.randrange(270))+50
- w3 = (random.randrange(200))+(w-210)
- h3 = (random.randrange(270))+50
- if not c: [c.append(z) for z in colors]
- objs.append(canvas.create_line(w2, h2, w3, h3, width=40, fill=c.pop()))
- canvas = Canvas(root, width=w, height=h)
- canvas.pack()
- #
- for z in '#'*10:
- randomobjs()
- #
- def after_loop():
- removeobjs()
- randomobjs()
- root.after(150, after_loop)
- after_loop()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement