Advertisement
here2share

# Tk_speed_of_graphics4.py

Apr 24th, 2020
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. # Tk_speed_of_graphics4.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. from time import clock
  7.  
  8. wi = 500
  9. he = 500
  10.  
  11. root = Tk()
  12. root.title("Speed of Graphics 4 on 500x500 per Pixel")
  13. root.geometry("500x500")
  14. w = Canvas(root, width=wi, height=he)
  15. w.pack()
  16.  
  17. print("Will Most Likely Take Under 30 Seconds To Initialize...")
  18. def data_process(y):
  19.     xy.extend([(y/2,random.randrange(255),0) for x in range(wi)]) # set the color accordingly
  20. #
  21. img = Image.new( 'RGB', (wi,he))
  22. frames = {}
  23. for z in range(40):
  24.     xy = []
  25.     for y in range(he):
  26.         data_process(y)
  27.     img.putdata(xy)
  28.     imgTk = ImageTk.PhotoImage(img)
  29.     frames[z] = imgTk
  30.  
  31. '''
  32. '''
  33. c = 40 # Should be at least 40 frames per second for a 2560x1440 screen
  34. raw_input("Press [Enter] To Commence...")
  35. start = clock()
  36. for z in frames:
  37.     w.create_image(0, 0, anchor=NW, image=frames[z])
  38.     root.update()
  39. #
  40. t = (clock()-start)*((2560*1440)/((wi*he)*1.0))
  41.  
  42. print("40 Frames In {:10.6f} Seconds".format(t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement