-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (25 loc) · 852 Bytes
/
Copy pathmain.py
File metadata and controls
35 lines (25 loc) · 852 Bytes
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
import pyxel
from calculator import Calculator
# TO DO
# Delete Operator class (or use it --> sin(3) can be written internally as s3, so 's' becomes a single-caracter operator)
# Usar mejores métodos de parsing: ej, no usar 'char in ("+", "-", ...)'
scl = 5
buttonW, buttonH = int(110 / scl), int(80 / scl)
WIDTH, HEIGHT = int(450 / scl), int(600 / scl)
calc = Calculator(WIDTH, HEIGHT, buttonW, buttonH)
def main():
pyxel.init(WIDTH, HEIGHT, title="Calculator", display_scale=scl)
pyxel.run(update, draw)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
pyxel.mouse(visible=True)
calc.checkButtons()
calc.checkKeyboard()
calc.display.checkCursor()
# print(pyxel.btn(pyxel.KEY_SHIFT), pyxel.btn(pyxel.KEY_PLUS))
def draw():
pyxel.cls(1)
calc.draw()
if __name__ == "__main__":
main()