-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.kv
97 lines (82 loc) · 2.34 KB
/
Calculator.kv
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
<Custom_Button@Button>:
font_size: 24
# Define the calculator layout
# Which can be referred to Layout Class
<CalcLayout>:
id: calculator
display: entry
rows: 6
padding: 10
spacing: 10
BoxLayout:
# When input triggered, updating entry
TextInput:
id: entry
font_size: 24
multiline: False
# Buttons of numbers
# Three numbers and a sign is a box, from up to down
BoxLayout:
spacing: 10
Custom_Button:
text: "1"
on_press: entry.text += self.text
Custom_Button:
text: "2"
on_press: entry.text += self.text
Custom_Button:
text: "3"
on_press: entry.text += self.text
Custom_Button:
text: "Delete"
on_press: calculator.delete(entry.text)
BoxLayout:
spacing: 10
Custom_Button:
text: "4"
on_press: entry.text += self.text
Custom_Button:
text: "5"
on_press: entry.text += self.text
Custom_Button:
text: "6"
on_press: entry.text += self.text
Custom_Button:
text: "Add"
on_press:entry.text += "+"
BoxLayout:
spacing: 10
Custom_Button:
text: "7"
on_press: entry.text += self.text
Custom_Button:
text: "8"
on_press: entry.text += self.text
Custom_Button:
text: "9"
on_press: entry.text += self.text
Custom_Button:
text: "Remove"
on_press: entry.text += "-"
BoxLayout:
spacing: 10
Custom_Button:
text: "."
on_press: entry.text += self.text
Custom_Button:
text: "0"
on_press: entry.text += self.text
Custom_Button:
text: "*"
on_press: entry.text += self.text
Custom_Button:
text: "Tax"
on_press: calculator.tax(entry.text)
BoxLayout:
Custom_Button:
font_size: 24
text: "AC"
on_press: entry.text = ""
Custom_Button:
text: "done"
on_press: calculator.calculate(entry.text)