Title: kivyMD Calling a variable into kivy language
Tags: python;python-3.x;kivy;kivy-language
Question: Im having a problem, the thing i want to do is to call a variable I have in kivymd language but it always give an error.

here is my code:

KV:

```<Main&gt;
    product: product

Screen:
    BoxLayout:
        size_hint: .8, .8
        pos_hint: {"center_x": .5, "y": .7}
        spacing: dp(100)
        orientation: "vertical"
        MDTextFieldRound:
            id: product
            hint_text: 'Enter a product'
            icon_left: 'magnify'
            on_text_validate: app.System() 

    FloatLayout:
        MDCard:
            orientation: "vertical"
            size_hint: .43, .3
            height: self.minimum_height
            pos_hint: {"x": .05, "y": .35}

            BoxLayout:
                id: box
                size_hint_y: None
                height: dp(150)

                MDLabel:
                    text: 'self.data_ebay'                # I want to call it here 

        MDCard:
            orientation: "vertical"
            size_hint: .43, .3
            height: self.minimum_height
            pos_hint: {"x": .52, "y": .35}

            BoxLayout:
                id: box
                size_hint_y: None
                height: dp(150)

        MDCard:
            orientation: "vertical"
            size_hint: .43, .3
            height: self.minimum_height
            pos_hint: {"x": .52, "y": .03}

            BoxLayout:
                id: box
                size_hint_y: None
                height: dp(150)

        MDCard:
            orientation: "vertical"
            size_hint: .43, .3
            height: self.minimum_height
            pos_hint: {"x": .05, "y": .03}

            BoxLayout:
                id: box
                size_hint_y: None
                height: dp(150)
```

PY:

```import kivy
from kivy.properties import ObjectProperty
from selenium import webdriver
import requests
from selectorlib import Extractor
from selenium.webdriver.common.keys import Keys
from kivymd.app import MDApp
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout

class Main(MDApp):
    Window.size = (310, 520)
    title = "Best Price"
    def build(self):
        return Builder.load_string(KV)

    product = ObjectProperty(None)
    def System(self):
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('headless')
        self.options.add_argument('window-size=1920x1080')
        self.options.add_argument("disable-gpu")

        self.browser = 
        webdriver.Chrome('C://Users//Yesnia//Documents//chromedriver_win32//chromedriver.exe', 
        options=self.options)

        self.browser.get('https://www.ebay.com/')

        self.Esearch = self.browser.find_element_by_name('_nkw')
        self.Esearch.send_keys(self.root.ids.product.text)
        self.Esearch.send_keys(Keys.ENTER)
        self.url = self.browser.current_url

        self.Ebay = Extractor.from_yaml_file('ebay.txt')
        self.r_ebay = requests.get(self.url)
        self.data_ebay = self.Ebay.extract(self.r_ebay.text)

        print('Ebay: ', self.data_ebay)                  # This is the variable

if __name__ == "__main__":
    Main().run()
```


Here is the accepted answer: i found a solution, the problem is that the variable is inside the class function, and when you call to app.data_ebay app refers to the class, you can add in the class this:

```class Main(MDApp):
    Window.size = (310, 520)
    title = "Best Price"
    def build(self):
        return Builder.load_string(KV)

    product = ObjectProperty(None)

    data_ebay = StringProperty()    #You can add this 
```

but data ebay has to be an 'str'


Here is another answer: You've asked this question 3 times now.


How to call a variable in .kv kivymd
AttributeError: &#39;NoneType&#39; on the selenium
this particular instance


I think both me and lothric provided very valuable methods of using variables in kv.
Please refer to the answers.
Please also note that when lothric mentions 'app.variable' he doesn't mean for you to literally place the variable in quotes as that just turns it into a string as you have done in your code.

In this instance:

```            MDLabel:
                ### text: 'self.data_ebay' <- you've turned this variable into a string which is not valid
                text: app.data_ebay
```

As lothric and I both mentioned, your method of calling variables is incorrect as you the MDLabel object does not have any data_ebay attribute, however your APP CLASS does. This is why you want to reference it using app.data_ebay.

Instead of starting separate questions for the same issue, please communicate more on the single question.

Thanks.

Comment for this answer: i try it with  text: app.data_ebay but it still giving me the same error:
Comment for this answer: this is the error:     AttributeError: 'Main' object has no attribute 'data_ebay'
   File "E:\pythonf2\lib\site-packages\kivy\lang\builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "", line 31, in 
   File "E:\pythonf2\lib\site-packages\kivy\lang\parser.py", line 76, in __getattribute__
     return getattr(object.__getattribute__(self, '_obj'), name)
Comment for this answer: that's because the variable doesn't exist until your System function runs. Since the variable doesn't exist when the kv language loads up, your label can't call the variable.
Assign the variable and give it some empty text in your App __init__ function.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:02/13/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><python-3.x><kivy><kivy-language>', 'Title': 'kivyMD Calling a variable into kivy language', 'ViewCount': 818, 'id': 60218211, 'user_AboutMe': '<p>Backend &amp; Frontend Developer✌️</p>\n<p>I have 4+ years of Experience working with Python and 2 years of Experience working with JavaScript, I handle all areas of Computer Science.</p>\n<pre><code>if (sad() == true) {\n   sad().stop();\n   beAwesome();\n};\n</code></pre>\n', 'user_AccountId': 17372683.0, 'user_DisplayName': 'Bernardo Olisan', 'user_Reputation': 561.0, 'user_Views': 131.0, 'user_id': 12586440.0}}