Search code examples
python-3.xkivy

How to use strings in kivy


I want want to use strings from my main python file to the .kv file but don't know what commands to use. I want to put the string in the label text

from kivy.app import App
import kivy.uix.label
import kivy.uix.button
from kivy.uix.boxlayout import BoxLayout

string1 = "hi"


class TestApp(BoxLayout):
    pass


class MyApp(App):
    def build(self):
        return TestApp()


if __name__ == '__main__':
    MyApp().run()

<TestApp>
    BoxLayout:
        Label:
            text: 'hi'

I tried searching all over the internet but couldn't find any solutions


Solution

  • I I figured it out. You should add a string property in your class to use that string