Advertisement
here2share

# Tk_256_Gradient.py

Apr 15th, 2020
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. # Tk_256_Gradient.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5.  
  6. root = Tk()
  7. root.title("256 Gradient")
  8. wt = 255
  9. ht = 255
  10. root.geometry("%dx%d+-10+0"%(wt,ht))
  11. canvas = Canvas(root, width=wt, height=ht)
  12. canvas.pack()
  13.  
  14. def gen(w,h):
  15.     for cy in xrange(h):
  16.         for cx in xrange(w):
  17.             r = 255-cx
  18.             g = 255-cy
  19.             b = (cx+cy)/2
  20.             t = (r,g,b)
  21.             rgb.append(tuple(t))
  22. 0
  23.  
  24. if 1:
  25.     rgb = []
  26.     gen(wt,ht)
  27.    
  28.     img = Image.new('RGB', (wt,ht))
  29.     img.putdata(rgb)
  30.     imgTk = ImageTk.PhotoImage(img)
  31.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  32.     root.update()
  33.     print len(rgb)
  34. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement