Advertisement
here2share

# Tk_non-parallel_pixels_500x500.py

Aug 17th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # Tk_speed_of_graphics.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6.  
  7. root = Tk()
  8. root.title("Speed of Graphics on 500x500 per Pixel")
  9. root.geometry("500x500")
  10. wi = 500
  11. he = 500
  12. w = Canvas(root, width=wi, height=he)
  13. w.pack()
  14.  
  15. def data_process(y):
  16.     xy.extend([(y/2,random.randrange(255),0) for x in range(wi)]) # set the color accordingly
  17. #
  18. img = Image.new( 'RGB', (wi,he))
  19. while 1:
  20.     xy = []
  21.     for y in range(he):
  22.         data_process(y)
  23.     img.putdata(xy)
  24.     imgTk = ImageTk.PhotoImage(img)
  25.     w.create_image(0, 0, anchor=NW, image=imgTk)
  26.     root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement