Advertisement
here2share

# Tk_1200x680_Each_Pixel_A_Random_Color_Test_4.py

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