Skip to content

Commit

Permalink
add tutorial 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kiok46 committed Jan 13, 2017
1 parent ed4a922 commit 53e32fb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Basic-App/kv/buttons.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<AddButton>:
text: "+1"
font_size: 50

<SubtractButton>:
text: "-1"
font_size: 50
13 changes: 13 additions & 0 deletions Basic-App/main.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Container>:
display: display
rows: 1
BoxLayout:
orientation: "vertical"
AddButton:
on_release: root.add_one()
SubtractButton:
on_release: root.subtract_one()
Label:
id: display
font_size: dp(50)
text: '0'
43 changes: 43 additions & 0 deletions Basic-App/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.properties import ObjectProperty
from kivy.uix.gridlayout import GridLayout


from os import listdir
kv_path = './kv/'
for kv in listdir(kv_path):
Builder.load_file(kv_path+kv)


class AddButton(Button):
pass


class SubtractButton(Button):
pass


class Container(GridLayout):
display = ObjectProperty()

def add_one(self):
value = int(self.display.text)
self.display.text = str(value+1)

def subtract_one(self):
value = int(self.display.text)
self.display.text = str(value-1)


class MainApp(App):

def build(self):
self.title = 'Awesome app!!!'
return Container()


if __name__ == "__main__":
app = MainApp()
app.run()

0 comments on commit 53e32fb

Please sign in to comment.