Kivy: How to correctly manipulate a widget in python that is defined in KV lang -
i have have following that's written in kv lang:
textinput: id: user_input_temp font_size: 50 size_hint_y: none input_filter: 'float' multiline: false label: text: "celsius" label: id: celsius text: root.temp_conv()
and attempt use user_input_temp
in python code:
class temperature(screen,boxlayout): def temp_conv(self): number = self.ids.user_input_temp.text input = float(number) celsius = (input - 32)*(5/9) self.ids.celsius.text = str(celsius)
but receive error - valueerror: not convert string float:
how can correctly convert .text
of widget? (preferably using widget id)
check value can't convert. in example, don't set text it's doing float('')
, give error see since ''
doesn't describe float. in case you'd want try conversion, return suitable or nothing @ if fails.
Comments
Post a Comment