Advertisement
here2share

# Tk_speed_of_graphics_ZERO.py

Apr 23rd, 2020
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # Tk_speed_of_graphics_ZERO.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. from time import clock
  7. import ast
  8.  
  9. root = Tk()
  10. root.title("Zero Animation on 500x500 per Pixel")
  11. root.geometry("500x500")
  12. wi = 500
  13. he = 500
  14. w = Canvas(root, width=wi, height=he)
  15. w.pack()
  16.  
  17. def data_process(y):
  18.     xy.extend([(y/2,random.randrange(255),0) for x in range(wi)]) # set the color accordingly
  19. #
  20. xy = []
  21. for y in range(he):
  22.     data_process(y)
  23. #xy = str(xy)
  24. img = Image.new( 'RGB', (wi,he))
  25. c = 40 # Should be at least 40 frames per second for a 2560x1440 screen
  26. start = clock()
  27. while c:
  28.     # zero animation
  29.     img.putdata(xy)
  30.     imgTk = ImageTk.PhotoImage(img)
  31.     w.create_image(0, 0, anchor=NW, image=imgTk)
  32.     root.update()
  33.     c = c - 1
  34. #
  35. t = int((clock()-start)*((2560*1440)/((wi*he)*1.0)))
  36. if t:
  37.     print("Needs To Be At Least %dx Faster"%t)
  38. else:
  39.     print("Congratulation... Minimal Speed Exceeded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement