from kivy.app import App
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.uix.label import Label
Balance = 0
Balance_string = str(Balance)
class MyWidget(Widget):
def ads(self):
global Balance
Balance += 0.25
Balance_string = str(Balance)
print(Balance_string)
return Balance_string
class BuzzMoneyApp(App):
def build(self):
return MyWidget()
if __name__ == '__main__':
BuzzMoneyApp().run()
** my .kv file **
<MyWidget>:
canvas:
Color:
rgb: (0, 150,0)
Rectangle:
pos: self.pos
size: self.size
Button:
center: self.parent.center
font_size: 14
height: 28
background_color: (1.0, 0.0, 0.0, 1.0)
text: "Earn money"
on_press:root.ads()
I want to access the Balance string variable from my main.py in my .kv file, so that I can display it on my screen.