Repository navigation
Expand file tree
/
Copy pathClickApp.py
More file actions
99 lines (69 loc) · 2.56 KB
/
Copy pathClickApp.py
File metadata and controls
99 lines (69 loc) · 2.56 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from kivy.app import App
from kivy.uix.button import Button
from kivy.animation import Animation
from kivy.properties import ObjectProperty, NumericProperty
from kivy.config import Config
from kivy.uix.label import Label
from kivy.clock import Clock
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
Config.set('graphics', 'resizable', False)
class AddButton(Button):
pass
class EasyButton(Button):
pass
class NormalButton(Button):
pass
class HardButton(Button):
pass
class CountDown(Label):
anim = None
time_counter = NumericProperty(20)
def start(self):
Animation.cancel_all(self) # stop any current animations
self.anim = Animation(time_counter=0, duration=self.time_counter)
self.anim.start(self)
class Mode(Screen):
def change_screen(self, count_down):
self.manager.current = 'clicker'
self.manager.ids.click_away.count = CountDown()
self.manager.ids.click_away.count.time_counter = count_down
self.manager.ids.click_away.count.start()
class ClickAway(Screen):
addButton = ObjectProperty()
countDown = ObjectProperty()
count = None
def __init__(self, **kwargs):
super(ClickAway, self).__init__(**kwargs)
self.count = CountDown()
Clock.schedule_interval(self.update, 1.0 / 60.0)
def update(self, *args):
self.countDown.text = str(round(self.count.time_counter, 1))
if float(self.countDown.text) < 1:
self.manager.current = 'end'
temp = 'You clicked the button {} time'.format(self.addButton.text)
clicks = int(self.addButton.text)
if clicks == 1:
self.manager.ids.end_screen.score.text = temp
else:
self.manager.ids.end_screen.score.text = temp + 's'
temp = 'That\'s a savings of ${} or {}%'.format(str(clicks * .00000031 * 850000), str(clicks * .000031))
self.manager.ids.end_screen.savings.text = temp
def add_one(self):
value = int(self.addButton.text)
self.addButton.text = str(value + 1)
def enable(self):
self.addButton.disabled = False
class End(Screen):
pass
class Manager(ScreenManager):
mode_screen = ObjectProperty(None)
click_away = ObjectProperty(None)
class ClickApp(App):
def build(self):
self.title = 'Away ISA!'
screen_manager = Manager(transition=SlideTransition())
return screen_manager
if __name__ == "__main__":
app = ClickApp()
app.run()