here2share

# Tk_seq_shuffle.py

Apr 15th, 2022 (edited)
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # Tk_seq_shuffle.py
  2.  
  3. from tkinter import *
  4. from PIL import Image, ImageTk
  5. from itertools import combinations
  6.  
  7. b2w = ((0,)*3,(255,)*3)
  8. b2w += b2w[::-1]
  9. b2w = list(b2w*125)+[(0,)*3]*500
  10.  
  11. ww = 600
  12. hh = 600
  13.  
  14. def draw():
  15.     image.putdata(rgb)
  16.     photo = ImageTk.PhotoImage(image)
  17.     canvas.create_image(0,0,image=photo,anchor=NW)
  18.     canvas.update()
  19.    
  20.  
  21. root = Tk()
  22. root.title("Tk_seq_shuffle")
  23. root.geometry("%dx%d+0+0"%(ww,hh))
  24.    
  25. canvas = Canvas(root, width=ww, height=hh)
  26. canvas.pack()
  27.  
  28. image = Image.new("RGB", (ww,hh), (255,255,255))
  29.  
  30. i = 1
  31. rgb = [(0,0,0)]*(ww*hh)
  32.  
  33. while 1:
  34.     ttt = []
  35.     for x in range(ww):
  36.         i += 1
  37.         t = b2w.pop(i%1000)
  38.         ttt += [t]
  39.         b2w += [t]
  40.     rgb.extend(ttt)
  41.     rgb = rgb[-ww*hh:]
  42.     draw()
Add Comment
Please, Sign In to add comment