How to print a text value on Kivy Screen

Viewed 495

I have a variable result = "some text" and I want to use the value of this variable to print it on the Kivy Screen through a Label

I have tried .py

class ScreenThree(Screen):
    def __init__(self, **kwargs):
        super(ScreenThree, self).__init__(**kwargs)
        result = "some text"

.kv

Label:
                    id: result_label
                    text: root.result

but as soon as i run the app, it stops immediately with an error for line text: root.result I have no idea how to print values on screen in kivy because I have recently started learning kivy.

Please let me know what I can do to print whatever is in the result variable on the screen

1 Answers

Use:

class ScreenThree(Screen):
    result = StringProperty("some text")
    def __init__(self, **kwargs):
        super(ScreenThree, self).__init__(**kwargs)
Related