Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_1D_Walk.py
- from PIL import Image, ImageTk, ImageDraw
- from tkinter import *
- import PIL
- import math
- import random
- ww = 1400
- hh = 600
- yy = hh/2
- root=Tk()
- root.title("Tk_1D_Walk")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root,width=ww,height=hh,bg='black')
- canvas.grid(row=0,column=0,sticky=N+S+E+W)
- 0
- def oRGB(rgb):
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- def plot():
- color = oRGB(rgb)
- x = xx+2
- canvas.create_line((x, 0, x, yy), fill=color)
- 0
- while 1:
- canvas.delete('all')
- for xx in range(0,ww):
- rgb = 255,255,0 # yellow
- yy = max(20,min(hh-20,yy+random.choice([-2,-1,0,1,2])))
- plot()
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement