Advertisement
AntonioVillanueva

TKINTER TIMER TEST

May 9th, 2019
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # coding: utf-8
  3. from tkinter import *
  4.  
  5. master = Tk()
  6.  
  7.  
  8. class clase:
  9.     lista_botones=[]
  10.     etiqueta=Label(text="Etiqueta",bg="red")
  11.     def __init__(self):
  12.         for b in range(10):
  13.             self.lista_botones.append( Button(text=str(b),bg="green") )
  14.             self.lista_botones[-1].pack()
  15.             #self.lista_botones[-1].configure(bg="blue")
  16.            
  17.         #etiqueta=Label(text="Etiqueta",bg="red")
  18.         self.etiqueta.pack()
  19.         self.etiqueta.after(1000,self.animate)
  20.            
  21.     def animate(self):
  22.         print ("Entra animate")
  23.         #mira la lista de botones
  24.         for b in self.lista_botones:
  25.             if b.cget("bg")=="green":
  26.                 b.configure(bg="yellow")
  27.             else:
  28.                 b.configure(bg="green")
  29.                
  30.         self.etiqueta.after(1000,self.animate)
  31.  
  32.  
  33.  
  34. botones=clase()
  35. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement