extrn

Untitled

Mar 24th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. root = Tk()
  4. lights = [Frame(root, width=200, height=200) for _ in range(3)]
  5.  
  6. colors = (
  7.     ('#FF0000', '#FFFF00', '#00FF00'),
  8.     ('#440000', '#444400', '#004400'),
  9. )
  10.  
  11. def update(counter=0):
  12.     for i, a in enumerate(lights):
  13.         a['bg'] = colors[i != counter % 3][i]
  14.  
  15.     root.after(500, update, counter + 1)
  16.  
  17. for a in lights:
  18.     a.pack()
  19.  
  20. update()
  21. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment