here2share

# Tk_no_ones.py

Feb 26th, 2022 (edited)
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # Tk_no_ones.py
  2.  
  3. from Tkinter import *
  4. from math import sqrt
  5. from random import shuffle as rs
  6.  
  7. def oRGB(rgb): # pass
  8.     r,g,b = rgb
  9.     return "#%02x%02x%02x" % (r,g,b)
  10.  
  11. ww = 600
  12. hh = 600
  13. root = Tk()
  14. root.title("# Tk_no_ones")
  15. root.geometry("%dx%d+0+0"%(ww,hh))
  16. canvas = Canvas(root, width=ww, height=hh)
  17. canvas.grid()
  18.    
  19. # set up spiral
  20. step = 1
  21. state = 0
  22. numSteps = 1
  23. turnCounter = 1
  24. stepSize = 5
  25. cols = ww / stepSize
  26. rows = hh / stepSize
  27. totalSteps = cols * rows
  28. x = ww / 2
  29. y = hh / 2
  30.  
  31. COLORS = 'red orange yellow green blue purple'.split()
  32. t = stepSize
  33. i = 12345
  34. iii = 1
  35. s = ''
  36. Lc = len(COLORS)
  37. while 1:
  38.     canvas.delete('all')
  39.     for y in range(0,hh,stepSize):
  40.         for x in range(0,ww,stepSize):
  41.             if len(s) < 100:
  42.                 s += str(i).replace('1','')
  43.                 i += 1
  44.             iii = int(s[:3])
  45.             s = s[3:]
  46.             color = int(iii)%Lc
  47.             canvas.create_rectangle((x,y,x+t,y+t), fill=COLORS[color], outline='')
  48.     canvas.update()
  49.  
Add Comment
Please, Sign In to add comment