Advertisement
here2share

# Tk_1200x680_Each_Pixel_A_Random_Color_Test_7.py

Apr 18th, 2021 (edited)
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. # Tk_1200x680_Each_Pixel_A_Random_Color_Test_7.py
  2.  
  3. # xrange()
  4. from Tkinter import Tk, Canvas, NW
  5. from PIL import Image, ImageTk
  6. import random
  7.  
  8. def oRGB(rgb): # pass
  9.     r,g,b = rgb
  10.     return "#%02x%02x%02x" % (r,g,b)
  11.  
  12. ww = 1200
  13. hh = 680
  14. root = Tk()
  15. root.title("Tk_1200x680_Each_Pixel_A_Random_Color_Test_7")
  16. root.geometry("%dx%d+0+0"%(ww,hh))
  17. canvas = Canvas(root, width=ww, height=hh)
  18. canvas.grid()
  19.  
  20. img = Image.new("RGB",(ww, hh))
  21.  
  22. while 1:
  23.     pix = []
  24.     for x in xrange (ww):
  25.         for y in xrange(hh):
  26.             pix.append(tuple([random.randint(0,255) for rgb in 'zzz']))
  27.     img.putdata(pix)
  28.     imgTk = ImageTk.PhotoImage(img)
  29.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  30.     canvas.update()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement