Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_256_Gradient.py
- from Tkinter import *
- from PIL import Image, ImageTk
- root = Tk()
- root.title("256 Gradient")
- wt = 255
- ht = 255
- root.geometry("%dx%d+-10+0"%(wt,ht))
- canvas = Canvas(root, width=wt, height=ht)
- canvas.pack()
- def gen(w,h):
- for cy in xrange(h):
- for cx in xrange(w):
- r = 255-cx
- g = 255-cy
- b = (cx+cy)/2
- t = (r,g,b)
- rgb.append(tuple(t))
- 0
- if 1:
- rgb = []
- gen(wt,ht)
- img = Image.new('RGB', (wt,ht))
- img.putdata(rgb)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
- print len(rgb)
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement