Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_spectrum_cycle.py
- from Tkinter import *
- root = Tk()
- root.title("Spectrum Cycle")
- root.geometry("120x120")
- wi = 120
- he = 120
- r = 0
- g = 0
- b = 255
- w = Canvas(root, width=wi, height=he, bg="grey")
- w.pack()
- def update():
- pass
- def color(r,g,b):
- c = '#%02x%02x%02x' %(r,g,b)
- try:
- w.create_rectangle(0,0,wi,he,fill=c)
- root.update()
- except: pass
- def run():
- global r,g,b
- # blue to violet
- for r in range(0, 255, 4):
- color(r,g,b)
- # violet to red
- for b in range(255, 0, -4):
- color(r,g,b)
- # red to yellow
- for g in range(0, 255, 4):
- color(r,g,b)
- # yellow to green
- for r in range(255, 0, -4):
- color(r,g,b)
- # green to teal
- for b in range(0, 255, 4):
- color(r,g,b)
- # teal to blue
- for g in range(255, 0, -4):
- color(r,g,b)
- root.after(1, run)
- run()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement