main_Schablone.py
main_Schablone.py — Python Source, 1 KB (1091 bytes)
Dateiinhalt
import kivy kivy.require ('1.9.0') from kivy.app import App from kivy.core.audio import SoundLoader from kivy.uix.boxlayout import BoxLayout from kivy.uix.image import Image from kivy.uix.button import Button class TierschauApp (App): def build(self): self.elter = BoxLayout (orientation = 'vertical') self.knopfleiste = BoxLayout (orientation = 'horizontal', size_hint = (1, .1)) self.bild = Image (source = 'leer.png', allow_stretch = True, size_hint = (1, .9)) self.elefantknopf = Button (text = 'Elefant') self.kolibriknopf = ... self.pinguinknopf = ... self.elefantknopf.bind (on_release = self.elefantklick) ... ... self.knopfleiste.add_widget (self.elefantknopf) ... ... self.elter.add_widget (...) self.elter.add_widget (...) return self.elter def elefantklick (self, obj): self.bild.source = 'Elefant.png' SoundLoader.load ('Elefant.wav').play () def ... def ... if __name__ == '__main__': TierschauApp ().run()