My app consists of 2 screens:
Screen 1 - 1 textinput widget and 1 button widget
Screen 2 - 1 textinput widget
On button press I want to capture the data entered in the textinput of Screen1 and print it in textinput of Screen2.
I have tried the following code but getting error:
main.py
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
class Screen1(Screen):
pass
class Screen2(Screen):
pass
class WindowManager(ScreenManager):
txtinp1 = ObjectProperty(None)
txtinp2 = ObjectProperty(None)
class ResultsApp(App):
def build(self):
return Builder.load_file("tutorials\Design3.kv")
def disp(self):
self.root.txtinp2.text = self.root.txtinp1.text
if __name__ == "__main__":
ResultsApp().run()
design3.kv
WindowManager:
Screen1:
Screen2:
<Screen1>
name:'main'
txtinp1:textinp1
GridLayout:
cols:1
TextInput:
id:textinp1
Button:
text:'Submit'
on_press:
app.root.current = 'second'
app.disp()
<Screen2>
name:'second'
txtinp2:textinp2
GridLayout:
cols:1
TextInput:
id:textinp2
The error I am getting is below.
File "c:/Users/pavan m sunder/projects/kivy/tutorials/tut7(kvlang).py", line 25, in disp
self.root.txtinp2.text = self.root.txtinp1.text
AttributeError: 'NoneType' object has no attribute 'text'
I tried looking for solutions in stackoverflow but couldn't find.