Skip to content

Commit

Permalink
Add buttons, add icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sswm1975 committed May 17, 2021
1 parent 80b8489 commit cbf6f3e
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 62 deletions.
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@ install:
- sudo apt install -y git
- git clone https://github.com/kivy/buildozer.git
- python3 -m site
- ls -l
- cd buildozer
- ls -l
- python3 setup.py install
- ls -l
- cd ..
- ls -l

- sudo apt update
- sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
- sudo apt install -y git zip unzip openjdk-8-jdk autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
- pip3 install --upgrade Cython==0.29.19 virtualenv
- export PATH=$PATH:~/.local/bin/
- ls -l
- yes | buildozer android debug
- ls -l
- ls bin/ -l
- echo "TODO"
- gem install dpl --pre
- dpl releases --token $GITHUB_TOKEN --file "bin/calculator-0.2-armeabi-v7a-debug.apk" --tag_name "v.0.2"
- echo "TODO 2"

- dpl releases --token $GITHUB_TOKEN --file "bin/calculator-0.3-armeabi-v7a-debug.apk" --tag_name "v.0.3"
- echo "END"
4 changes: 2 additions & 2 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source.dir = .
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = 0.2
version = 0.3

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
Expand All @@ -46,7 +46,7 @@ requirements = python3,kivy==2.0.0
#presplash.filename = %(source.dir)s/data/logo/presplash512okmin.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/logo/logo512min.png
icon.filename = %(source.dir)s/logo512.png

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = all
Expand Down
107 changes: 66 additions & 41 deletions calculator.kv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Container>:
orientation: 'vertical'
padding: 10
padding: 4

label_info: id_label_info
label_input: id_label_input
Expand Down Expand Up @@ -28,69 +28,94 @@
cols: 4

Button:
text: "7"
on_press:
root.add_number(self)
text: "1"
on_release:
root.add_in_formula(self)
Button:
text: "8"
on_press:
root.add_number(self)
text: "2"
on_release:
root.add_in_formula(self)
Button:
text: "9"
on_press:
root.add_number(self)
text: "3"
on_release:
root.add_in_formula(self)
Button:
text: "*"
on_press:
root.add_number(self)
text: "+"
background_color: "grey"
on_release:
root.add_in_formula(self)

Button:
text: "4"
on_press:
root.add_number(self)
on_release:
root.add_in_formula(self)
Button:
text: "5"
on_press:
root.add_number(self)
on_release:
root.add_in_formula(self)
Button:
text: "6"
on_press:
root.add_number(self)
on_release:
root.add_in_formula(self)
Button:
text: "-"
on_press:
root.add_number(self)
background_color: "grey"
on_release:
root.add_in_formula(self)

Button:
text: "1"
on_press:
root.add_number(self)
text: "7"
on_release:
root.add_in_formula(self)
Button:
text: "2"
on_press:
root.add_number(self)
text: "8"
on_release:
root.add_in_formula(self)
Button:
text: "3"
on_press:
root.add_number(self)
text: "9"
on_release:
root.add_in_formula(self)
Button:
text: "+"
on_press:
root.add_number(self)
text: "x"
background_color: "grey"
on_release:
root.add_in_formula(self)

Button:
text: "/"
on_press:
root.add_number(self)
text: "+/-"
on_release:
root.set_sign(self)
Button:
text: "0"
on_press:
root.add_number(self)
on_release:
root.add_in_formula(self)
Button:
text: "."
on_press:
root.add_number(self)
on_release:
root.add_in_formula(self)
Button:
text: "/"
background_color: "grey"
on_release:
root.add_in_formula(self)

Button:
text: "("
background_color: "lightblue"
on_release:
root.add_in_formula(self)
Button:
text: ")"
background_color: "lightblue"
on_release:
root.add_in_formula(self)
Button:
text: "C"
background_color: "red"
on_release:
root.clear_formula(self)
Button:
text: "="
on_press:
background_color: "yellow"
on_release:
root.calc_result(self)
Binary file added logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 38 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,53 @@ class Container(BoxLayout):
label_input = ObjectProperty()
formula = ''

def add_number(self, instance):
def add_in_formula(self, instance):
if self.label_info.text == 'Error':
self.label_info.color = 'yellow'
self.label_info.text = ''

self.formula += str(instance.text)
self.label_input.text = self.formula

def calc_result(self, instance):
self.label_info.text = self.formula
self.label_input.text = str(eval(self.formula))
def set_sign(self, instance):
if self.formula[0] == '-':
self.formula = self.formula[1:]
else:
self.formula = '-' + self.formula

self.label_input.text = self.formula

def clear_formula(self, instance):
self.formula = ''
self.label_input.text = ''
self.label_info.text = ''

def calc_result(self, instance):
if self.formula == '':
return

try:
calc = str(eval(self.formula.replace('x', '*')))
except:
self.label_info.color = 'red'
self.label_info.text = 'Error'
calc = False

if calc:
if len(calc) > 2 and calc[-2:] == '.0':
calc = calc[:-2]

self.label_input.text = calc
self.label_info.text = self.formula + ' ='
self.formula = calc


class CalculatorApp(App):
title = "Калькулятор"
icon = "logo512.png"

def build(self):
return Container()


if __name__ == '__main__':
CalculatorApp().run()
CalculatorApp().run()

0 comments on commit cbf6f3e

Please sign in to comment.