I am trying to create a simple countdown timer, i want to be able to restart it on the Button click, right now it won't start other, i just can not get it right. What am i missing here?
the KV
<RootWidget>:
#:import randint random.randint
orientation: "vertical"
CountDownLbl:
id: anim_label
text: "{0:.3f}".format(float(self.startCount - self.angle / 360))
font_size: 30
canvas:
Color:
rgb: 0,1,0
Line:
circle:self.center_x, self.center_y, 90, 0, self.angle % 360
width: 30
Button:
size_hint_y: 0.1
text: "Start"
on_press: anim_label.start()
and the code
COUNT=1
class RootWidget(FloatLayout):
pass
class CountDownLbl(Label):
startCount = COUNT
angle = NumericProperty(0)
def __init__(self, **kwargs):
super(CountDownLbl, self).__init__(**kwargs)
def start(self):
self.startCount = COUNT
self.anim = Animation(angle=360 * self.startCount, duration=self.startCount)
self.in_progress = True
self.anim.start(self)
class TestApp(App):
def build(self):
return RootWidget()
if __name__ == '__main__':
TestApp().run()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…