
#autotymer here?
class Tymer(object):
  def __init__(self, description, max, action):
    self.max = max 
    self.cnt = self.max 
    self.act = action
    self.desc= description
  def __call__(self):
    if self.cnt > 0:
      exec self.act

shrink= Tymer("shrink", 150, "th0+=5 \nth1-=5 \nta0+=5 \nta1+= 5 \nself.cnt -= 1") 
pause= Tymer("pause", 20, "\nself.cnt -= 1") 
grow = Tymer("grow", 150, "th0-=5 \nth1+=5 \nta0-=5 \nta1-= 5 \nself.cnt -= 1") 
dwell= Tymer("dwell", 30, "\nself.cnt -= 1") 

timers=[shrink, pause, grow, dwell]

def autotymer():
    notDoneList=[ t for t in timers if t.cnt>0]
    if len(notDoneList)==0:
      for j in timers:
         j.cnt = j.max
    else:
      foo = notDoneList[0]
      print foo.desc," counter =", foo.cnt 
      foo()  # top timer active
 
