I need to know how to convert kivy textInput strings in to floats inside of my .kv file or a better way to do arithmetic inside of my .kv file. I've been using the line of code below to concatenate my strings and do arithmetic this way, but it's been returning a syntax error for a few set of strings. -
"{:.8f}".format(float(str(eval(...THIS IS WHERE MY STRINGS GO...))))
I use devoted strings for the multiplication, division, addition, and subtraction symbols and it has worked without fail for most problems (key word "most").
You must be sure that here is always something to evaluate, if the string to evaluate is empty it will fail even the first time.
You also dont need to cast the result of eval().
You can do the operation after an event, like this
....
TextInput:
id: output
Button:
text: "="
on_release: output.text = "{:.8f}".format(eval(output.text))
....