Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __version__ = '1.0'
- from kivy.app import App
- from kivy.uix.widget import Widget
- from kivy.core.window import Window
- from kivy.clock import Clock
- Window.clearcolor = (1, 1, 1, 1)
- from kivy.uix.listview import ListItemButton
- from kivy.properties import StringProperty, ListProperty, NumericProperty
- from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
- from kivy.graphics.vertex_instructions import Ellipse
- import os
- from functools import partial
- from kivy.uix.carousel import Carousel
- from kivy.uix.image import AsyncImage
- # from kivy.config import config
- from kivy.core.text import LabelBase
- import pyobjus.debug
- from pyobjus.pyobjus import autoclass
- import random
- LabelBase.register(name="Varela",
- fn_regular="data/varela-round-v6-latin-regular.ttf",
- fn_bold="data/varela-round-v6-latin-regular.ttf",
- fn_italic="data/varela-round-v6-latin-regular.ttf",
- fn_bolditalic="data/varela-round-v6-latin-regular.ttf")
- KIVY_DEFAULT_FONT = 'Varela'
- DEFAULT_FONT = KIVY_DEFAULT_FONT
- TEXT_SIZE = 36
- TROLL_SIZE = 50
- COUNT_BY = .055
- secCounter = 0
- secCounterTtl = 0
- repCounter = 0
- repCounterRd = 0
- rdCounter = 1
- repDummy = 0
- frcCounter = 0
- frcCounterRd = 0
- rdGoal = False
- countRound = False
- trollEnergy = 100
- trollDiff = 1
- class Workouts(Screen):
- pass
- class TrollLevel(Screen):
- def set_troll_diff(self, *args):
- global trollDiff
- if self.ids.diff_slider.value == 0:
- trollDiff = .1
- else:
- trollDiff = self.ids.diff_slider.value / 5
- self.manager.current = 'troll'
- class Troll(Screen):
- def start_clock(self, widget):
- global secCounter
- secCounter+=.01
- ls = [i for i in range(0,7)]
- for i in ls:
- i2 = 5 - i
- Clock.schedule_once(partial(self.change_start_text, i2), i)
- def count_round(self, widget):
- global countRound
- countRound=True
- def change_start_text(self,index, *args):
- self.ids.start_button.text = str(int(index)) + '...'
- if index < 1:
- self.ids.start_button.text = 'GO!!!'
- if index < 0:
- self.ids.start_button.pos_hint = {'center_x': 100, 'center_y': 100}
- self.ids.start_button.text = 'START'
- self.ids.troll_img.pos_hint = {'center_x': .5, 'center_y': .5}
- Clock.schedule_interval(self.ticks.update_clock, .05)
- def troll_hurt(self, *args):
- self.ids.troll_img.source = 'data/troll.png'
- def troll_dead(self, *args):
- self.ids.troll_img.source = 'data/troll.png'
- self.ids.troll_img.height = 40
- def stop_clock(self):
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter
- self.disp_sec = secCounter = 0
- self.disp_rep = repCounter = 0
- self.disp_rep_rd = repCounterRd = 0
- self.disp_frc = frcCounter = 0
- self.disp_frc_rd = frcCounterRd = 0
- self.disp_troll_energy = trollEnergy = 100
- self.disp_sec_ttl = str(0)
- secCounterTtl = 0
- rdCounter = 0
- self.ids.disp_rds.text = str(rdCounter)
- self.e2_end = 180
- self.e1_end = 0
- self.ids.troll_img.height = 40
- Clock.unschedule(self.ticks.update_clock)
- self.ids.start_button.pos_hint = {'center_x': .5, 'center_y': .5}
- self.ids.eaten_txt.pos_hint = {'center_x': 100, 'center_y': 100}
- self.manager.current = 'workouts'
- class TicksTroll(Widget):
- def __init__(self, **kwargs):
- super(TicksTroll, self).__init__(**kwargs)
- self.bind(pos=self.update_clock)
- self.bind(size=self.update_clock)
- def update_clock(self, *args):
- def reset_color(*args):
- self.parent.flash_color = '#F7F7F7'
- global secStart, secCounter, repCounter, repDummy, frcCounter, countRound
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter, rdGoal
- global trollDiff, trollEnergy
- self.canvas.clear()
- self.parent.disp_sec = round(secCounter,1)
- if secCounterTtl > 60:
- mins = int(secCounterTtl / 60)
- secs = secCounterTtl % 60
- secs = str(round(secs,1))
- if len(secs)< 4:
- secs = '0'+secs
- self.parent.disp_sec_ttl = str(mins) + ':' + secs
- else:
- self.parent.disp_sec_ttl = str(round(secCounterTtl,1))
- if secCounter>0:
- with self.canvas:
- secCounter+=COUNT_BY
- secCounterTtl+=COUNT_BY
- repDummy+=COUNT_BY
- ran = random.random()
- if ran < .1:
- trollDiff
- self.parent.ids.troll_img.height = self.parent.ids.troll_img.height+(10*trollDiff)
- if repDummy > 3:
- repCounter+=1
- repCounterRd+=1
- frcCounter+=22
- frcCounterRd+=22
- trollEnergy-=22
- self.parent.flash_color = '#98DCB6'
- Clock.schedule_once(reset_color, .25)
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- self.parent.disp_frc = frcCounter
- self.parent.disp_frc_rd = frcCounterRd
- self.parent.disp_troll_energy = trollEnergy
- repDummy=0
- self.parent.ids.troll_img.height = self.parent.ids.troll_img.height-20
- self.parent.ids.troll_img.source = 'data/troll_hurt.png'
- Clock.schedule_interval(self.parent.troll_hurt, .5)
- degrees = (secCounter / 60) * 360
- if trollEnergy < 0:
- rdCounter+=1
- self.parent.disp_troll_energy = trollEnergy = 100
- self.parent.ids.disp_rds.text = str(rdCounter)
- self.parent.e1_end = 0
- self.parent.e2_end = 180
- # secCounter=0.00001
- repCounterRd=0
- # self.parent.e2_start = 0
- # self.parent.e2_end = 0
- # countRound=False
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- # self.parent.disp_frc = frcCounter
- # self.parent.disp_frc_rd = frcCounterRd
- self.parent.ids.troll_img.source = 'data/troll_dead.png'
- Clock.schedule_once(self.parent.troll_dead, .25)
- if self.parent.ids.troll_img.height > 250:
- self.parent.ids.troll_img.pos_hint = {'center_x': 100, 'center_y': 100}
- self.parent.ids.eaten_txt.pos_hint = {'center_x': .5, 'center_y': .5}
- self.disp_sec = secCounter = 0
- self.disp_rep = repCounter = 0
- self.disp_rep_rd = repCounterRd = 0
- self.disp_frc = frcCounter = 0
- self.disp_frc_rd = frcCounterRd = 0
- rdCounter = 0
- self.parent.ids.disp_rds.text = str(rdCounter)
- Clock.unschedule(self.update_clock)
- else:
- self.parent.e1_end = degrees
- class Free(Screen):
- def start_clock(self, widget):
- global secCounter
- secCounter+=.01
- ls = [i for i in range(0,7)]
- for i in ls:
- print('i:',i)
- i2 = 5 - i
- print('i2:',i2)
- Clock.schedule_once(partial(self.change_start_text, i2), i)
- def count_round(self, widget):
- global countRound
- countRound=True
- def change_start_text(self,index, *args):
- print('index:', index)
- self.ids.start_button.text = str(int(index)) + '...'
- if index < 1:
- self.ids.start_button.text = 'GO!!!'
- if index < 0:
- self.ids.start_button.pos_hint = {'center_x': 100, 'center_y': 100}
- Clock.schedule_interval(self.ticks.update_clock, .05)
- self.ids.start_button.text = 'START'
- self.ids.count_rd_button.pos_hint = {'center_x': .5, 'center_y': .7}
- self.ids.done_button.pos_hint = {'center_x': .5, 'center_y': .3}
- def stop_clock(self):
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter
- print(self.ids.keys())
- self.disp_sec = secCounter = 0
- self.disp_rep = repCounter = 0
- self.disp_rep_rd = repCounterRd = 0
- self.disp_frc = frcCounter = 0
- self.disp_frc_rd = frcCounterRd = 0
- rdCounter = 0
- self.ids.disp_rds.text = str(rdCounter)
- self.e2_end = 180
- self.e1_end = 0
- Clock.unschedule(self.ticks.update_clock)
- self.ids.start_button.pos_hint = {'center_x': .5, 'center_y': .5}
- self.manager.current = 'workouts'
- class TicksFree(Widget):
- def __init__(self, **kwargs):
- super(TicksFree, self).__init__(**kwargs)
- self.bind(pos=self.update_clock)
- self.bind(size=self.update_clock)
- def update_clock(self, *args):
- def reset_color(*args):
- self.parent.flash_color = '#F7F7F7'
- global secStart, secCounter, repCounter, repDummy, frcCounter, countRound
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter, rdGoal
- self.canvas.clear()
- self.parent.disp_sec = round(secCounter,1)
- if secCounterTtl > 60:
- mins = int(secCounterTtl / 60)
- secs = secCounterTtl % 60
- secs = str(round(secs,1))
- if len(secs)< 4:
- secs = '0'+secs
- self.parent.disp_sec_ttl = str(mins) + ':' + secs
- else:
- self.parent.disp_sec_ttl = str(round(secCounterTtl,1))
- if secCounter>0:
- with self.canvas:
- secCounter+=COUNT_BY
- secCounterTtl+=COUNT_BY
- repDummy+=COUNT_BY
- if repDummy > 3:
- repCounter+=1
- repCounterRd+=1
- frcCounter+=53
- frcCounterRd+=53
- self.parent.flash_color = '#98DCB6'
- Clock.schedule_once(reset_color, .25)
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- self.parent.disp_frc = frcCounter
- self.parent.disp_frc_rd = frcCounterRd
- repDummy=0
- degrees = (secCounter / 60) * 360
- if countRound:
- rdCounter+=1
- self.parent.ids.disp_rds.text = str(rdCounter)
- self.parent.e1_end = 0
- self.parent.e2_end = 180
- secCounter=0.00001
- frcCounterRd=0
- repCounterRd=0
- self.parent.e2_start = 0
- self.parent.e2_end = 0
- countRound=False
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- self.parent.disp_frc = frcCounter
- self.parent.disp_frc_rd = frcCounterRd
- else:
- self.parent.e1_end = degrees
- class EMOM(Screen):
- def start_clock(self, widget):
- global secCounter
- secCounter+=.01
- ls = [i for i in range(0,7)]
- for i in ls:
- print('i:',i)
- i2 = 5 - i
- print('i2:',i2)
- Clock.schedule_once(partial(self.change_start_text, i2), i)
- def change_start_text(self,index, *args):
- print('index:', index)
- self.ids.start_button.text = str(int(index)) + '...'
- if index < 1:
- self.ids.start_button.text = 'GO!!!'
- if index < 0:
- self.ids.start_button.pos_hint = {'center_x': 100, 'center_y': 100}
- self.ids.work_flag.text = 'WORK'
- Clock.schedule_interval(self.ticks.update_clock, .05)
- self.ids.start_button.text = 'START'
- def stop_clock(self):
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter
- print(self.ids.keys())
- self.ids.work_flag.text = ''
- self.disp_sec = secCounter = 0
- self.disp_rep = repCounter = 0
- self.disp_rep_rd = repCounterRd = 0
- self.disp_frc = frcCounter = 0
- self.disp_frc_rd = frcCounterRd = 0
- rdCounter = 0
- self.ids.disp_rds.text = str(rdCounter)
- self.e2_end = 180
- self.e1_end = 0
- Clock.unschedule(self.ticks.update_clock)
- self.ids.start_button.pos_hint = {'center_x': .5, 'center_y': .5}
- self.manager.current = 'workouts'
- class TicksEMOM(Widget):
- def __init__(self, **kwargs):
- super(TicksEMOM, self).__init__(**kwargs)
- self.bind(pos=self.update_clock)
- self.bind(size=self.update_clock)
- def update_clock(self, *args):
- def reset_color(*args):
- self.parent.flash_color = '#F7F7F7'
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter, rdGoal
- self.canvas.clear()
- self.parent.disp_sec = round(secCounter,1)
- self.parent.disp_sec_ttl = round(secCounterTtl,1)
- if secCounter>0:
- with self.canvas:
- secCounter+=COUNT_BY
- secCounterTtl+=COUNT_BY
- repDummy+=COUNT_BY
- if repDummy > 3:
- repCounter+=1
- repCounterRd+=1
- frcCounter+=53
- frcCounterRd+=53
- self.parent.flash_color = '#98DCB6'
- Clock.schedule_once(reset_color, .25)
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- self.parent.disp_frc = frcCounter
- self.parent.disp_frc_rd = frcCounterRd
- repDummy=0
- degrees = (secCounter / 60) * 360
- if repCounterRd == 8 and not rdGoal:
- rdGoal=True
- self.parent.e2_start = degrees
- self.parent.e2_end = degrees
- self.parent.ids.work_flag.text = 'REST'
- elif degrees >= (360-.05):
- rdCounter+=1
- self.parent.ids.disp_rds.text = str(rdCounter)
- self.parent.e1_end = 0
- self.parent.e2_end = 180
- secCounter=0.00001
- frcCounterRd=0
- repCounterRd=0
- self.parent.ids.work_flag.text = 'WORK'
- self.parent.e2_start = 0
- self.parent.e2_end = 0
- rdGoal=False
- elif repCounterRd >= 8:
- self.parent.e2_end = degrees
- else:
- self.parent.e1_end = degrees
- class OnOff(Screen):
- def start_clock(self, widget):
- global secCounter
- secCounter+=.01
- ls = [i for i in range(0,7)]
- for i in ls:
- print('i:',i)
- i2 = 5 - i
- print('i2:',i2)
- Clock.schedule_once(partial(self.change_start_text, i2), i)
- def change_start_text(self,index, *args):
- print('index:', index)
- self.ids.start_button.text = str(int(index)) + '...'
- if index < 1:
- self.ids.start_button.text = 'GO!!!'
- if index < 0:
- self.ids.start_button.pos_hint = {'center_x': 100, 'center_y': 100}
- self.ids.work_flag.text = 'WORK'
- Clock.schedule_interval(self.ticks.update_clock, .05)
- self.ids.start_button.text = 'START'
- def stop_clock(self):
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter
- print(self.ids.keys())
- self.ids.work_flag.text = ''
- self.disp_sec = secCounter = 0
- self.disp_rep = repCounter = 0
- self.disp_rep_rd = repCounterRd = 0
- self.disp_frc = frcCounter = 0
- self.disp_frc_rd = frcCounterRd = 0
- rdCounter = 0
- self.ids.disp_rds.text = str(rdCounter)
- self.e2_end = 180
- self.e1_end = 0
- Clock.unschedule(self.ticks.update_clock)
- self.ids.start_button.pos_hint = {'center_x': .5, 'center_y': .5}
- self.manager.current = 'workouts'
- class Ticks(Widget):
- def __init__(self, **kwargs):
- super(Ticks, self).__init__(**kwargs)
- self.bind(pos=self.update_clock)
- self.bind(size=self.update_clock)
- def update_clock(self, *args):
- def reset_color(*args):
- self.parent.flash_color = '#F7F7F7'
- global secStart, secCounter, repCounter, repDummy, frcCounter
- global secCounterTtl, repCounterRd, frcCounterRd, rdCounter
- self.canvas.clear()
- self.parent.disp_sec = round(secCounter,1)
- self.parent.disp_sec_ttl = round(secCounterTtl,1)
- if secCounter>0:
- with self.canvas:
- secCounter+=COUNT_BY
- secCounterTtl+=COUNT_BY
- repDummy+=COUNT_BY
- if repDummy > 3:
- repCounter+=1
- repCounterRd+=1
- frcCounter+=53
- frcCounterRd+=53
- self.parent.flash_color = '#98DCB6'
- Clock.schedule_once(reset_color, .25)
- self.parent.disp_rep = repCounter
- self.parent.disp_rep_rd = repCounterRd
- self.parent.disp_frc = frcCounter
- self.parent.disp_frc_rd = frcCounterRd
- repDummy=0
- degrees = (secCounter / 60) * 360
- if degrees >= (360-.05):
- rdCounter+=1
- self.parent.ids.disp_rds.text = str(rdCounter)
- self.parent.e1_end = 0
- self.parent.e2_end = 180
- secCounter=0.00001
- frcCounterRd=0
- repCounterRd=0
- self.parent.ids.work_flag.text = 'WORK'
- elif degrees >= 180.5:
- self.parent.e2_end = degrees
- self.parent.ids.work_flag.text = 'REST'
- else:
- self.parent.e1_end = degrees
- class Login(Screen):
- def do_login(self, loginText, passwordText):
- app = App.get_running_app()
- app.username = loginText
- app.password = passwordText
- self.manager.transition = SlideTransition(direction="left")
- self.manager.current = 'workouts'
- app.config.read(app.get_application_config())
- app.config.write()
- def resetForm(self):
- self.ids['login'].text = ""
- self.ids['password'].text = ""
- class ForceApp(App):
- username = StringProperty(None)
- password = StringProperty(None)
- data = ListProperty(["Item #{0}".format(i) for i in range(50)])
- def build(self):
- manager = ScreenManager()
- manager.add_widget(Login(name='login'))
- manager.add_widget(Workouts(name='workouts'))
- manager.add_widget(OnOff(name='onoff'))
- manager.add_widget(EMOM(name='emom'))
- manager.add_widget(Free(name='free'))
- manager.add_widget(TrollLevel(name='troll_level'))
- manager.add_widget(Troll(name='troll'))
- return manager
- def get_application_config(self):
- if(not self.username):
- return super(ForceApp, self).get_application_config()
- conf_directory = self.user_data_dir + '/' + self.username
- if(not os.path.exists(conf_directory)):
- os.makedirs(conf_directory)
- return super(ForceApp, self).get_application_config(
- '%s/config.cfg' % (conf_directory)
- )
- if __name__ == '__main__':
- ForceApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement