Sorry my english. How can I send some text from popup to label in another class which is inherited from the Screen class? I tried different options for accessing this object, but nothing happens. It looks like text sends to another object, because these objects has different memory adresses. I checked it. Comment indicating the problem is in the code:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.popup import Popup
Builder.load_string("""
#:import Factory kivy.factory.Factory
<Keyboard>:
text_input: text_input
BoxLayout:
orientation: 'vertical'
TextInput:
id: text_input
Button:
text: 'Send text'
on_release: root.send()
<Container>:
label: label
BoxLayout:
orientation: 'vertical'
Label:
id: label
text: 'Here must some be text from popup'
Button:
text: 'My popup'
on_release: Factory.Keyboard().open()
Button:
text: 'Goto options'
on_press: root.manager.current = 'Options'
<Options>:
BoxLayout:
Button:
text: 'Back to time'
on_press: root.manager.current = 'Time'
""")
class Options(Screen):
def show_kv(self, instance, value):
self.manager.current = value
class Container(Screen):
pass
class Keyboard(Popup):
def send(self):
try:
time = self.text_input.text
except:
time = ''
# Here is some problem
Container().label.text = time # Nothing happens
self.dismiss()
class KivyApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(Container(name='Time'))
sm.add_widget(Options(name='Options'))
sm.current = "Time"
return sm
if __name__ == '__main__':
KivyApp().run()