Accessing String from .py file to TextInput of .kv file

24 views
Skip to first unread message

Ketaki Kulkarni

unread,
Apr 24, 2018, 9:00:48 AM4/24/18
to Kivy users support
Hello,
When I press a button I want text from the string in the TextInput of .kv file.

.py file
class A():
    input=StringProperty(' ')
    def fun1():
        input=something

.kv file
Button:
        id: grammar_button
        text: 'Check Grammar'
        on_release: self.main()

TextInput:
        text:????? - Here I want to get the text of "input" and display it in GUI.

Thank you.
Regards,
Ketaki

ZenCODE

unread,
Apr 25, 2018, 4:09:47 PM4/25/18
to Kivy users support
Try putting together some run-able code that we can help you with. There are too many unknowns/issues with the code above to be helpful.

Thanks

Ketaki Kulkarni

unread,
Apr 25, 2018, 10:26:13 PM4/25/18
to Kivy users support


Edit :
Now I have added my two files and a screenshot.Please have a look on it .
Thank you
main.py
speech.kv
i1.png

ZenCODE

unread,
Apr 26, 2018, 8:16:49 AM4/26/18
to Kivy users support
You can add a method to your Root class.

class Root(BoxLayout):

def print_text(self, text):
print("Tesxt is ", text)

Then just call if from you kv file. In speech.kv

GrammarButton:

id: grammar_button
text: 'Check Grammar'
    # on_press : self.main()
# on_release : text1.text=grammar_button.final_text
height: '50dp'
size_hint_y: None
on_release: root.print_text(text1.text)

Reply all
Reply to author
Forward
0 new messages