0

I will write simple code to understanding better , imagine we have 3 Button in kivy file like bellow code

kivy file:

Button:
   text: A1
   variable = 3
Button:
   text : A2
   variable = 2
Button:
   text :A3
   variable = 3

how I can put variable in kivy file when I prese on each button the variable change according value we defined, then deal with varable in python file

py file

def btn(self):
    new_variable= variable+5
Sam
  • 35
  • 2
  • 8

1 Answers1

0

You can use a text input :

kivi

Label:
   id:label
   text:'here is displayed the final result'

#here you insert content of variable
TextInput:
    id: txt_inpt
    text: '' 
    font_size:16

Button:
    text: 'A1'
    on_press: root.func()

Python:

def func():
    var= self.ids.txt_inpt.text
    addvar = int(var) + 5
    self.ids.label.text = str(addvar)