Advertisement
here2share

# Tk_spectrum_cycle.py

Jun 13th, 2015
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. # Tk_spectrum_cycle.py
  2.  
  3. from Tkinter import *
  4.  
  5. root = Tk()
  6. root.title("Spectrum Cycle")
  7. root.geometry("120x120")
  8. wi = 120
  9. he = 120
  10.  
  11. r = 0
  12. g = 0
  13. b = 255
  14.  
  15. w = Canvas(root, width=wi, height=he, bg="grey")
  16. w.pack()
  17.  
  18. def update():
  19.     pass
  20.  
  21. def color(r,g,b):
  22.     c = '#%02x%02x%02x' %(r,g,b)
  23.     try:
  24.         w.create_rectangle(0,0,wi,he,fill=c)
  25.         root.update()
  26.     except: pass
  27.  
  28. def run():
  29.     global r,g,b
  30.  
  31.     # blue to violet
  32.     for r in range(0, 255, 4):
  33.         color(r,g,b)
  34.  
  35.     # violet to red
  36.     for b in range(255, 0, -4):
  37.         color(r,g,b)
  38.  
  39.     # red to yellow
  40.     for g in range(0, 255, 4):
  41.         color(r,g,b)
  42.  
  43.     # yellow to green
  44.     for r in range(255, 0, -4):
  45.         color(r,g,b)
  46.  
  47.     # green to teal
  48.     for b in range(0, 255, 4):
  49.         color(r,g,b)
  50.  
  51.     # teal to blue
  52.     for g in range(255, 0, -4):
  53.         color(r,g,b)
  54.  
  55.     root.after(1, run)
  56.  
  57. run()
  58. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement