-
Notifications
You must be signed in to change notification settings - Fork 0
/
timers.py
35 lines (26 loc) · 1.12 KB
/
timers.py
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
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from shared import Shared
class Timers(BoxLayout):
def __init__(self, **kwargs):
super(Timers, self).__init__(**kwargs)
middle_label = Label(text="", size_hint=(1 - 6 / 40, 1))
self.right_label = Label(text="00:00/00:00", size_hint=(6 / 40, 1), halign='right')
Shared.get_total_length = self.update_total_length
Shared.update_current_pos = self.update_current_pos
Shared.clear_timer = self.clear_timer
Shared.timer_beginning = self.set_beginning
self.add_widget(middle_label)
self.add_widget(self.right_label)
def update_total_length(self, leng):
temp = self.right_label.text.split("/")
temp[1] = leng
self.right_label.text = "/".join(temp)
def update_current_pos(self, leng):
temp = self.right_label.text.split("/")
temp[0] = leng
self.right_label.text = "/".join(temp)
def clear_timer(self):
self.right_label.text = "00:00/00:00"
def set_beginning(self, leng):
self.right_label.text = f"00:00/{leng}"