Home > Software engineering >  Returning values from TextInputs in Kivy
Returning values from TextInputs in Kivy

Time:12-03

does anyone know how to return the string of a textinput in a kivy widget? The textinput is created inside the kv.file.

<OrderScreen>:
BoxLayout:
    TextInput:
        size_hint: (.2, None)
        pos_hint: {"center_y":0.5}
        height: 30
        width: 100
        hint_text: "Food"
        multiline: False
        id: input

CodePudding user response:

Yes, you can return the string of a TextInput widget in Kivy by using the text property of the TextInput widget. For example:

textinput = self.ids['my_textinput']
textinput_string = textinput.text

Here is an example of a Kivy TextInput widget:

TextInput:
    id: my_textinput
    multiline: False
    font_size: 20
    size_hint: .5, .2
    pos_hint: {'center_x': .5, 'center_y': .5}
  • Related