-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
40 lines (34 loc) · 1.53 KB
/
runner.py
File metadata and controls
40 lines (34 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.animation import Animation
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty, BooleanProperty
class Runner(BoxLayout):
value = NumericProperty(0) #сколько приседаний сделано
finished = BooleanProperty(False) #сделаны ли все приседания
def __init__(self, total=10, steptime=1, autorepeat=True, bcolor=(0.73, 0.15, 0.96, 1), btext_inprogress="Приседание", **kwargs):
super().__init__(**kwargs)
self.total = total
self.autorepeat = autorepeat
self.btext_inprogress = btext_inprogress
self.animation = (Animation(pos_hint={'top':0.1}, duration=steptime/2)
+ Animation(pos_hint={'top':1.0}, duration = steptime/2))
self.animation.on_progress = self.next
self.btn = Button(size_hint=(1, 0.1), pos_hint={'top':1.0}, background_color=bcolor)
self.add_widget(self.btn)
'''def restart(self, total):
self.total = total
self.start()'''
def start(self):
self.value = 0
self.finished = False
self.btn.text = self.btext_inprogress
if self.autorepeat:
self.animation.repeat = True
self.animation.start(self.btn)
def next(self, widget, step):
if step == 1.0:
self.value+=1
if self.value >= self.total:
self.animation.repeat = False
self.finished = True