Here’s the completed button using the Pythagorean Theorem to calculate. It looks to see which of the three textfields is blank then calculates what it should be based on the input of the other two.
def button3_tapped(sender):
if (v['textfield3'].text)!="" and (v['textfield4'].text)!="":
hyp = float(v['textfield3'].text)
sht = float(v['textfield4'].text)
hyp = pow(hyp,2)
sht = pow(sht,2)
lng = math.sqrt(hyp - sht)
v['textfield5'].text_color = 'green'
v['textfield5'].text = str(lng)
elif (v['textfield4'].text)!="" and (v['textfield5'].text)!="":
sht = float(v['textfield4'].text)
lng = float(v['textfield5'].text)
sht = pow(sht,2)
lng = pow(lng,2)
hyp = math.sqrt(sht + lng)
v['textfield3'].text_color = 'green'
v['textfield3'].text = str(hyp)
elif (v['textfield3'].text)!="" and (v['textfield5'].text)!="":
hyp = float(v['textfield3'].text)
lng = float(v['textfield5'].text)
hyp = pow(hyp,2)
lng = pow(lng,2)
sht = math.sqrt(hyp - lng)
v['textfield4'].text_color = 'green'
v['textfield4'].text = str(sht)
else:
v['textfield5'].text_color = 'red'
v['textfield5'].text = 'ENTER ALL FIELDS' ```