Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from kivy.app import App
- from kivy.uix.button import Button
- from kivy.uix.label import Label
- from kivy.uix.floatlayout import FloatLayout
- from kivy.clock import Clock
- import time
- START = int(time.time())
- n = 0
- def current_time(seconds):
- return str(seconds // 60) + ' minutes ' + str(seconds % 60) + ' seconds'
- def main():
- global n
- app = Main()
- n += 1
- return app
- def callback(instance, value):
- pass
- string = "You haven't played Dota for:\n" + current_time(0)
- height = 550
- width = 350
- class TimeLabel(Label):
- def update(self, *args):
- self.text = "You haven't played Dota for:\n" + current_time(int(time.time()) - START)
- class Main(App):
- def build(self):
- global string
- global height
- global width
- self.layout = FloatLayout(size = (width, height))
- self.but1 = Button(text='Motivation', font_size=14, size_hint = (.45, .15),
- pos_hint = {'x' : 0.02857142857142857, 'y' : 0.02857142857142857})
- self.but2 = Button(text='Achievements', font_size=14, size_hint = (.45, .15),
- pos_hint = {'x' : 0.5142857142857142, 'y' : 0.02857142857142857})
- self.but3 = Button(text='Stats', font_size=14, size_hint = (.45, .15), pos_hint = {'x' : 0.02857142857142857,
- 'y' : 0.2})
- self.but4 = Button(text='Advice', font_size=14, size_hint = (.45, .15), pos_hint = {'x' : 0.5142857142857142,
- 'y' : 0.2})
- self.text = TimeLabel()
- self.but1.bind(state=callback)
- self.but2.bind(state=callback)
- self.but3.bind(state=callback)
- self.but4.bind(state=callback)
- self.layout.add_widget(self.but1)
- self.layout.add_widget(self.but2)
- self.layout.add_widget(self.but3)
- self.layout.add_widget(self.but4)
- self.layout.add_widget(self.text)
- self.text.font_size = 24
- Clock.schedule_interval(self.text.update, 1)
- return self.layout
- def my_callback(self, dt):
- self.text = "You haven't played Dota for:\n" + current_time(int(time.time() - START))
- app = main()
- if __name__ in ('__main__', '__android__'):
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement