Sou iniciante no python e quero que sempre que um determinado botão seja apertado, execute uma função. Aqui está o código:
application.py
import kivy
kivy.require("1.8.0")
from kivy.app import App
class application(App):
def printar(self):
print("Hello World")
application().run()
application.kv
BoxLayout:
orientation: "vertical"
BoxLayout:
spacing: 130
padding: [30, 30, 30, 30]
size_hint: [1, .1]
orientation: "horizontal"
Button:
id: option
text: "Options"
Label:
text: "Connected"
bold: True
color: [0, 1, 0, .8]
font_name: "DejaVuSans"
Button:
id: onoff
text: "On/Off"
BoxLayout:
orientation: "horizontal"
spacing: 20
padding: [30, 30, 30, 30]
TextInput:
size_hint: [.7, .05]
pos_hint: {"y": .5}
multiline: False
hint_text: "Write"
Button:
id: send
text: "Send"
size_hint: [.2, .05]
pos_hint: {"y": .5}
on_release: root.printar()