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
| #chat
# coding: utf-8
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
class ChatApp(App):
def build(self):
Layout=BoxLayout(orientation='vertical',spacing=20,padding=(200,20))
#On cree un bouton:
self.BoutonChat=Button(text='Clique moi!',background_normal="kitty.png")
self.BoutonChat.bind(on_press=self.miaule)
Layout.add_widget(self.BoutonChat)
self.LabelChat=Label(text='Appuie sur le chat', font_size=20)
Layout.add_widget(self.LabelChat)
return Layout
def miaule(self,instance):
#import ipdb; ipdb.set_trace()
sound = SoundLoader.load("meow.ogg")
if sound:
print ( "Sound found at %s " % sound . source )
print ( "Sound is %.3f seconds" % sound . length )
sound.play
else:
print("pas de fichier son en lecture")
if __name__ == '__main__':
ChatApp().run() |
Partager