Advertisement
here2share

# Tk_random_putdata.py

Sep 26th, 2021
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. # Tk_random_putdata.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6.  
  7. ww = 600
  8. hh = 600
  9. root = Tk()
  10. root.title("Tk_random_putdata")
  11. root.geometry("%dx%d+0+0"%(ww,hh))
  12.  
  13. def rgb2hex(r,g,b):
  14.     return '#%02X%02X%02X'%(r,g,b)
  15.  
  16. def draw():
  17.     image.putdata([random.randrange(16777215) for _ in range(360000)])
  18.     photo = ImageTk.PhotoImage(image)
  19.     canvas.create_image(0,0,image=photo,anchor=NW)
  20.     canvas.update()
  21. 0
  22.  
  23. canvas = Canvas(root, width=ww, height=hh)
  24. canvas.pack()
  25.  
  26.  
  27. image = Image.new("RGB", (600,600), (255,255,255))
  28.  
  29. while 1:
  30.     draw()
  31. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement