1

Não consigo fazer com que a mesma função faça duas operações diferentes no 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()

Arquivo Kivy:

<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

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .