Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_250x250_Each_Pixel_A_Random_Color.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- def oRGB(rgb): # pass
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- ww = 250
- hh = 250
- root = Tk()
- root.title("Tk 250x250 Each Pixel A Random Color")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- img = Image.new("RGB",(ww, hh))
- while 1:
- pix = []
- for x in range (ww):
- for y in range(hh):
- pix.append(tuple([random.randint(0,255) for rgb in 'zzz']))
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement