Advertisement
here2share

# Tk_speed_of_graphics_ZERO_2.py

Apr 24th, 2020
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # Tk_speed_of_graphics_ZERO_2.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. img.putdata(xy)
  28. imgTk = ImageTk.PhotoImage(img)
  29. w.create_image(0, 0, anchor=NW, image=imgTk)
  30. root.update()
  31. while c:
  32.     # zero animation tail end measure
  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