Advertisement
here2share

# Tk_xrange_pixels.py

Dec 5th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # Tk_xrange_pixels.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6.  
  7. root = Tk()
  8. root.title("Xrange_Pixels")
  9. wi = 400
  10. he = 240
  11. root.geometry("%dx%d"%(wi, he))
  12. w = Canvas(root, width=wi, height=he)
  13. w.pack()
  14.  
  15. def data_process(y):
  16.     xy.extend([(0,random.randrange(y+15, 255),0) for x in xrange(wi)]) # set the color accordingly
  17. #
  18. img = Image.new( 'RGB', (wi,he))
  19. while 1:
  20.     xy = []
  21.     for y in xrange(he):
  22.         data_process(y)
  23.     img.putdata(xy)
  24.     imgTk = ImageTk.PhotoImage(img)
  25.     #time.sleep(0.02)
  26.     w.create_image(0, 0, anchor=NW, image=imgTk)
  27.     root.update()
  28. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement