0
I’m creating a piano with kivy working all right, but only with the click of the mouse on the Button , I want to know how to type a key the Button run without I have to click with the mouse
from kivy.uix.button import Button
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.boxlayout import BoxLayout
class Piano(App):
def build(self):
c = Button(text='C',font_size=30,on_release=self.do)
d = Button(text='D', font_size=30, on_release=self.re)
e = Button(text='E', font_size=30, on_release=self.mi)
f = Button(text='F', font_size=30, on_release=self.fa)
g = Button(text='G', font_size=30, on_release=self.sol)
a = Button(text='A', font_size=30, on_release=self.la)
b = Button(text='B', font_size=30, on_release=self.si)
box = BoxLayout()
box.add_widget(c)
box.add_widget(d)
box.add_widget(e)
box.add_widget(f)
box.add_widget(g)
box.add_widget(a)
box.add_widget(b)
return box`
def do (self,c):
som = SoundLoader.load('Songs/do.wav')
som.play()
def re (self,d):
som = SoundLoader.load('Songs/re.wav')
som.play()
def mi (self,e):
som = SoundLoader.load('Songs/mi.wav')
som.play()
def fa(self,f):
som = SoundLoader.load('Songs/fa.wav')
som.play()
def sol (self,g):
som = SoundLoader.load('Songs/sol.wav')
som.play()
def la (self,a):
som = SoundLoader.load('Songs/la.wav')
som.play()
def si (self,b):
som = SoundLoader.load('Songs/si.wav')
som.play()
if __name__ in '__main__':
Piano().run()
Please edit the question and enter the code you already have. The way it is, it will be difficult to answer exactly what you need.
– Woss