Advertisement
here2share

# Tk_shade_pattern.py

Jan 6th, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # Tk_shade_pattern.py # Red, Green, Blue... and Yellow
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. import math
  7. import time
  8.  
  9. wt = 255
  10. ht = 255
  11. root = Tk()
  12. root.title("Tk Shade Pattern")
  13. root.geometry("%dx%d+0+0"%(wt,ht))
  14. canvas = Canvas(root, width=wt, height=ht)
  15. canvas.grid()
  16.  
  17. # create new image
  18. img = Image.new("RGB",(wt,ht), "white")
  19.  
  20. if 1:
  21.     xy = []
  22.     for x in range(wt):
  23.         for y in range(ht):
  24.             t = x**2-y**2
  25.             xy.append((x%255, y%255, t%255))
  26.     img.putdata(xy)
  27.     imgTk = ImageTk.PhotoImage(img)
  28.     time.sleep(1)
  29.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  30.     root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement