class Demo(object): def __init__(self, root): self.root = root self.fade = Fade(256) #default 0-255 self.label = Label(root, text="text", fg="#000000", font=("Arial", 54)) self.label.pack() Button(root, text="Reset", command=self.reset).pack() self.fade_more() def reset(self): self.fade.reset() self.fade_more() def fade_more(self): try: current = self.fade.next() self.label.config(fg=dec2hex(current)) #configures text to next color self.label.pack() root.after(100, self.fade_more) except StopIteration: return
def test_reset(): f = Fade(10) for each in f: pass f.reset() assert f.index == 0