O
O
O0O0O0 0O0O0O2021-01-17 12:18:53
Python
O0O0O0 0O0O0O, 2021-01-17 12:18:53

Problem with Kivy Language?

How to pass a variable that is in a kv file to the rest of the code?
Here is an example:

KV = '''
Screen:
    MDRaisedButton:
        text: 'button'
        pos_hint: {'center_x':.5,'center_y':.4}
        on_press: app.func()
    MDTextField:
        id: text
        pos_hint: {'center_x':.5,'center_y':.5}
'''
class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)
    def func():
        print(text.text)

How can I make the code see the text variable and print it? I really need help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
Umpiro, 2021-01-17
@Umpiro

Here is the section from the official documentation that you are probably looking for.
https://kivy.org/doc/stable/guide/lang.html#access...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question