1
I can’t get the same function to do two different operations in the kivy:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class Topografia(BoxLayout):
def aa(self):
a = int(self.ids.input0.text)
b = int(self.ids.input1.text)
s = a + b
su = a - b
self.ids.apertado.text = '{}'.format(s)
self.ids.apertado.text = '{}'.format(su)
class NoobApp(App):
def build(self):
return Topografia()
if __name__ == '__main__':
NoobApp().run()
Kivy archive:
<Topografia>
orientation:'vertical'
Label:
text:'A:'
TextInput:
id: input0
text:''
Label:
text:'B:'
TextInput:
id: input1
text:''
Label:
text: 'Soma?'
BoxLayout:
Button:
id: sim
text:'soma'
on_release:root.aa()
Button:
id: nao
text:'subtração'
on_release:root.aa()
Label:
text:'Resultado: '
TextInput:
id: apertado