I have a simple program with a spinner widget to select a direction. I need to pass that direction as a variable that can be used in other classes. In the code below, I just want to print the direction in my main app class
#main.py
from kivy.uix.widget import Widget
from kivy.app import App
class MenuKV(Widget):
spun = False
value = str
def on_spinner_select(self, value):
# print (val)
self.value = value
self.spun = True
class MenuScreen(App):
def build(self):
if MenuKV.spun == True:
print ("your Going "+ MenuKV.value)
MenuScreen().run()
#kv file #menuscreen.kv
MenuKV:
<MenuKV>:
BoxLayout:
orientation: 'horizontal'
pos_hint: {"x":0, "top":1}
size_hint: 1, None
height: "44dp"
width: "200dp"
spacing: "10dp"
padding: "10dp"
pos: 0, root.height - 60
Spinner:
id: direction
text: 'North'
values: 'North', 'South', 'East', 'West'
on_text:
value = direction.text
root.on_spinner_select(value)
Button:
text: "future dev"