3

I have to do:

TextInput:
    on_text: something ; something_else

How can I perform this without getting errors in kv language?

mattogol
  • 33
  • 3

2 Answers2

3

You could just add more on_text bindings, line by line:

TextInput:
    on_text: something
    on_text: something_else

But I'd prefer binding custom function call, because I'm not sure order of execution is always the same with the above example. Something like this:

MyTextInput:
    on_text: self.custom_function()

and in python:

class MyTextInput(TextInput):
    def custom_function(self):
        something()
        something_else()
user
  • 5,370
  • 8
  • 47
  • 75
kilbee
  • 403
  • 1
  • 4
  • 13
  • This appears to be partially incorrect, multiple on_text do not seem to work. However according to this... https://kivy.org/docs/api-kivy.lang.html?highlight=lang#value-expressions-on-property-expressions-ids-and-reserved-keywords You can have multiple lines so long as they do not change the indent level and have \ at the end of the line – Jim Morris May 10 '17 at 00:02
3

As pointed out by Jim Morris, the (currently accepted) answer by kilbee is not correct and "feels" quiet dirty (in both variations).

The following works for me and "feels" like a clean solution:

TextInput:
    on_text:
        something
        something_else
ChristophK
  • 733
  • 7
  • 20