Advertisement
here2share

# Tk_250x250_Each_Pixel_A_Random_Color_Test_3.py

Mar 19th, 2021
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. # Tk_250x250_Each_Pixel_A_Random_Color_Test_3.py
  2.  
  3. from Tkinter import *
  4. import random
  5.  
  6. def oRGB(rgb): # pass
  7.     r,g,b = rgb
  8.     return "#%02x%02x%02x" % (r,g,b)
  9.  
  10. ww = 250
  11. hh = 250
  12. root = Tk()
  13. root.title("Tk 250x250 Each Pixel A Random Color")
  14. root.geometry("%dx%d+0+0"%(ww,hh))
  15. canvas = Canvas(root, width=ww, height=hh)
  16. canvas.grid()
  17.  
  18. pix = PhotoImage(width=ww, height=hh)
  19. while 1:
  20.     for x in range (ww):
  21.         for y in range(hh):
  22.             rgb = oRGB([random.randint(0,255) for rgb in 'zzz'])
  23.             pix.put(rgb, (x, y))
  24.     canvas.create_image(0, 0, image=pix, anchor='nw')
  25.     canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement