-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalc_toolboxpc.kv
196 lines (180 loc) · 6.34 KB
/
Calc_toolboxpc.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# ---------- calculator.kv ----------
# Custom button
<CustButton@Button>:
font_size: 32
background_color: 0, 0.7, 0.3, 1
<CustButton2@Button>:
font_size: 50
background_color: 0.5, 0.7, 0, 1
<CustButton3@Button>:
font_size: 60
background_color: 1, 0, 0, 1
<CustButton4@Button>:
font_size: 20
background_color: 0, 0.5, 0.8, 1
# Define id so I can refer to the CalcGridLayout
# class functions
# Display points to the entry widget
<Calculadora>:
id: calculator
display: entry
rows: 3
padding: 2
ActionBar:
id: actBar
background_color: 0, 0.7, 0.3, 1
ActionView:
ActionPrevious:
title: 'Calculadora' # Texto identificador do menu
with_previous: False
app_icon: 'images/logo.png'
markup:True
on_press: history.text = "Bem vindo a Calculadora by Neo"
on_release: history.text = calculator.ler_historico()
ActionButton:
text: 'M+'
on_press: history.text += entry.text + "\n"
on_release: entry.text = ''
ActionButton:
text: 'M-'
# on_press: calculator.historico(history.text)
on_release: history.text =''
ActionButton:
text: 'MRC'
on_press: calculator.memoria()
ActionButton:
icon: 'images/power.png'
on_press: calculator.gravar_historico(history.text)
on_release: calculator.confirmacao()
BoxLayout:
orientation: 'vertical'
size_hint_y: 0.45
BoxLayout:
size_hint_y: 0.3
TextInput:
id: history
font_size: 50
#keyboard: ''
pos_text: 'right_mid'
multiline: True
text: calculator.ler_historico()
# Where input is displayed
BoxLayout:
TextInput:
id: entry
font_size: 60
keyboard: None
halign: 'right'
multiline: True
BoxLayout:
orientation: 'vertical'
size_hint_y: .4
# When buttons are pressed update the entry
BoxLayout:
spacing: 1
CustButton3:
text: "AC"
on_press: entry.text = ""
CustButton2:
text: "7"
on_press: entry.text += self.text
CustButton2:
text: "8"
on_press: entry.text += self.text
CustButton2:
text: "9"
on_press: entry.text += self.text
CustButton:
text: "/"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += self.text
CustButton:
text: "%"
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.percentagem(entry.text)
CustButton4:
text: "Bin"
on_press: calculator.limpar_entrada(entry.text)
on_release: entry.text = calculator.decimal_bin(entry.text)
BoxLayout:
spacing: 1
CustButton:
text: '<--'
on_press: calculator.apaga_digito(entry.text)
CustButton2:
text: "4"
on_press: entry.text += self.text
CustButton2:
text: "5"
on_press: entry.text += self.text
CustButton2:
text: "6"
on_press: entry.text += self.text
CustButton:
text: "x"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += '*'
CustButton:
text: "!"
on_press: entry.text += self.text
CustButton4:
text: "Dec"
on_press: calculator.limpar_entrada(entry.text)
on_release: entry.text = calculator.bin_decimal(entry.text)
BoxLayout:
spacing: 1
CustButton:
text: "IMC"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += 'i'
CustButton2:
text: "1"
on_press: entry.text += self.text
CustButton2:
text: "2"
on_press: entry.text += self.text
CustButton2:
text: "3"
on_press: entry.text += self.text
CustButton:
text: "-"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += self.text
CustButton:
text: "Exp"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += self.text
CustButton4:
text: "Sum Bin"
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.soma_bin(entry.text)
# When equals is pressed pass text in the entry
# to the calculate function
BoxLayout:
spacing: 1
CustButton:
text: "P.I."
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.peso_ideal(entry.text)
CustButton:
text: "."
on_press: entry.text += self.text
CustButton2:
text: "0"
on_press: entry.text += self.text
CustButton:
text: "="
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.calculate(entry.text)
CustButton:
text: "+"
on_press: calculator.atualiza(entry.text)
on_release: entry.text += self.text
CustButton:
text: "#2"
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.sqrt_2(entry.text)
CustButton4:
text: "FIB"
on_press: calculator.limpar_entrada(entry.text)
on_release: calculator.fibonacci(entry.text)