Please if you like my content Please do not forget to support this channel on PayPal now for $1 only! Or less
from kivy.core.audio import SoundLoader
from kivy.uix.boxlayout import BoxLayout
from kivy.app import App
from kivy.properties import StringProperty
class CounterApp(App):
pass
class Counterscreen(BoxLayout):
text = StringProperty("0")
count = 0
reset1 = SoundLoader.load("Audio/reset1.wav")
click = SoundLoader.load("Audio/click.wav")
def clicksound(self):
self.click.play()
def resetsound(self):
self.reset1.play()
def add(self):
self.count +=1
self.text = str(self.count)
def subtract(self):
self.count -=1
self.text = str(self.count)
def reset(self):
self.count = 0
self.text = str(self.count)
CounterApp().run()
KV FILE
Counterscreen:
<Counterscreen>:
Label:
text: root.text
Button:
text: "+"
on_press: root.add() , root.clicksound()
color: 0,1,2,1
Button:
text: "-"
on_press: root.subtract() , root.clicksound()
color: 0,1,2,1
Button:
text: "Reset"
on_press: root.reset(), root.resetsound()
color: 0,1,2,1
No comments:
Post a Comment