Home>

How can a kv file variable refer to a py file variable using self?

The fact is that App is inherent only to classes, and self -only to functions.

The kv file variable only accepts app:

'' '
MDFlatButton:
    id: flat
    text: app.gg
'' '
class Test (MDApp):
    gg= '123'

But I need it to work like this:

MDFlatButton:
    id: flat
    text: self.gg
class Test (MDApp):
    def build (self):
        gg= '123'

to refer to a variable inside a function requires self, which does not accept kv. Question: how to make it work and not give an error?

MDFlatButton: id: flat text: self.gg

Or something else, but so that the buttonMDFlatButtontook an argumenttextfrom function.

Help(