Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_1200x680_Each_Pixel_A_Random_Color_Test_6.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import multiprocessing as mp
- from random import choice as rnd
- import time
- def oRGB(rgb): # pass
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- ww = 1200
- hh = 680
- root = Tk()
- root.title("Tk_1200x680_Each_Pixel_A_Random_Color_Test_5")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- RGBs = []
- def z():
- RGBs.append((r,g,b))
- r,g,b = 255,0,0
- for g in range(256):
- z()
- for r in range(254, -1, -1):
- z()
- for b in range(256):
- z()
- for g in range(254, -1, -1):
- z()
- for r in range(256):
- z()
- for b in range(254, -1, -1):
- z()
- img = Image.new("RGB",(ww, hh))
- def my_function():
- result = []
- for z in range(ww):
- result += [rnd(RGBs)]
- return result
- def get_result(result):
- pix.extend(result)
- if __name__ == '__main__':
- while 1:
- pix = []
- pool = mp.Pool(mp.cpu_count())
- for i in range(0, hh):
- pool.apply_async(my_function, args=(), callback=get_result)
- pool.close()
- pool.join()
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement