i want to use text entered by the user on one screen in other screens too as a title(button or a label)











up vote
1
down vote

favorite












currently i am storing all the text input by the user in a file.
when i run this code the screenfive buttons text root.a and root.b are the previous entries but not the present textinput entered.



meaning that in the first execution i had input firstname1 and lastname1 on the screen four.in the screen five's button i see with ( with )
because this is the first time the files are created so there is no text in them.



in the second execution i type fistname2 and lastname2 in screen four but when i move to screen five it displays 'firstname1 with firstname1' in the button's text but i am expecting 'firstname2 with lastname2' which was what i entered during the present execution
this is the python code:



 from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scatter import Scatter
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.config import Config
from kivy.base import runTouchApp

from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, NumericProperty, StringProperty


root = FloatLayout()

class ScreenManagement(ScreenManager):
pass

class A(Screen):
pass

class B(Screen):
pass

class C(Screen):
pass

class ScreenFour(Screen):
group_text_input = ObjectProperty()
disability_text_input = ObjectProperty()

grouptextinput = StringProperty('')
disabilitytextinput = StringProperty('')

global grouptextinput, disabilitytextinput

def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
self.save2()

def save(self):
with open("grouptextinput.txt", "w") as fobj:
fobj.write(str(self.grouptextinput))
def save2(self):
with open("disabilitytextinput.txt", "w") as fobj:
fobj.write(str(self.disabilitytextinput))
pass

class Help(Screen):
pass

class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
print 'file is opened'
a = myfile.readline(14)
print a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
b = myfile.readline(14)
print b

## a = box.grouptextinput
## b = box.grouptextinput

pass

class ScreenSix(Screen):
pass

class One(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Two(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Three(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Four(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Five(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Six(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Seven(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Eight(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Nine(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

presentation = Builder.load_file("main.kv")

class MainApp(App):



def build(self):
return presentation

if __name__ == "__main__":
MainApp().run()


and this is the kivy code:



#: import FadeTransition kivy.uix.screenmanager.FadeTransition

ScreenManagement:
transition: FadeTransition()
A:
B:
C:
ScreenFour:
Help:
ScreenFive:
ScreenSix:
One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
Nine:

<A>:
name: "llll"
Button:
on_release: app.root.current = "iiii"
Image:
source: '************'
center_x: self.parent.center_x
center_y: self.parent.center_y

<Intentions>:
name: "iiii"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "pppp"
pos: 590,50
size: 200, 60

<Picot>:
name: "pppp"
Image:
source: '****************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFour>
name: "screenfour"
group_text_input: group
disability_text_input: disability
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: "**********"
font_size: '47sp'
pos: 0, 100
color: 0,0,0,1
bold: True

TextInput:
id: group
multiline: False
size_hint_x: .3
size_hint_y: .1
hint_text: '************'
pos: 90, 220
font_size: '29sp'

Label:
text:"********"
font_size: '40sp'
pos: 0, -50
color: 0,0,0,1
bold: True

TextInput:
id: disability
multiline: True
size_hint_x: .3
size_hint_y: .1
hint_text: '*********'
pos: 465, 220
font_size: '29sp'

Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfive"
on_release: root.submit_textinput()
pos: 590,50
size: 200, 60

Button:
text: 'Help!'
id: button
font_size: 30
size_hint: None, None
on_release: app.root.current = "help"
pos: 50,50
size: 100, 60

<Help>
name: "help"
Image:
source: '******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: '*********'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFive>
name:"screenfive"
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: '********'
font_size: '60sp'
pos: 0, 150
color: 0,0,0,1
bold: True

Label:
text: '**********'
font_size: '53sp'
pos: 0, 75
color: 0,0,0,1
bold: True

Label:
text: '*******'
font_size: '60sp'
pos: 0, 0
color: 0,0,0,1
bold: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size: 760, 100
size_hint: None, None
pos: 20,150
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1

Button:
text: 'Continue'
id: button
font_size: 40
size: 200, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 590,50

<ScreenSix>
name: "menu"
canvas:
Color:
rgb: .5, .5, .5
Rectangle:
size: self.size

GridLayout:
cols: 3
spacing: 20
padding: [20,50]
Label:
text: ''
Label:
text: '************'
font_size: '19sp'
Label:
text: ''
Button:
text: '********'
#on_press: root.manager.current = 'settings'
on_release: app.root.current = "one"
Button:
text: '*******'
on_release: app.root.current = "two"
Button:
text: '*****'
on_release: app.root.current = "three"
Button:
text: '********'
on_release: app.root.current = "four"
Button:
text: '********'
on_release: app.root.current = "five"
Button:
text: '********'
on_release: app.root.current = "six"
Button:
text: '*******'
on_release: app.root.current = "seven"
Button:
text: '*********'
on_release: app.root.current = "eight"
Button:
text: '***********'
on_release: app.root.current = "nine"

<One>
name: "one"
Image:
source: '********'
y: self.parent.y
x: self.parent.x
allow_stretch: True

Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
allow_stretch: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Two>
name: "two"
Image:
source: '*******'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Three>
name: "three"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Four>
name: "four"
Image:
source: '*************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Five>
name: "five"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Six>
name: "six"
Image:
source: '************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Seven>
name: "seven"
Image:
source: '*******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Eight>
name: "eight"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Nine>
name: "nine"
Image:
source: '***************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80


i am new to python and kivy both and this is the last thing which is holding me up from building my first app.i would be very thankful if someone could help me out.










share|improve this question
























  • The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
    – John Anderson
    Nov 12 at 17:20










  • Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
    – John Anderson
    Nov 12 at 17:22










  • hey john anderson,
    – Yashas A
    Nov 13 at 13:09










  • thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
    – Yashas A
    Nov 13 at 13:10










  • the code runs absolutely fine with just this glitch. my doubt in precise is :
    – Yashas A
    Nov 13 at 13:13















up vote
1
down vote

favorite












currently i am storing all the text input by the user in a file.
when i run this code the screenfive buttons text root.a and root.b are the previous entries but not the present textinput entered.



meaning that in the first execution i had input firstname1 and lastname1 on the screen four.in the screen five's button i see with ( with )
because this is the first time the files are created so there is no text in them.



in the second execution i type fistname2 and lastname2 in screen four but when i move to screen five it displays 'firstname1 with firstname1' in the button's text but i am expecting 'firstname2 with lastname2' which was what i entered during the present execution
this is the python code:



 from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scatter import Scatter
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.config import Config
from kivy.base import runTouchApp

from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, NumericProperty, StringProperty


root = FloatLayout()

class ScreenManagement(ScreenManager):
pass

class A(Screen):
pass

class B(Screen):
pass

class C(Screen):
pass

class ScreenFour(Screen):
group_text_input = ObjectProperty()
disability_text_input = ObjectProperty()

grouptextinput = StringProperty('')
disabilitytextinput = StringProperty('')

global grouptextinput, disabilitytextinput

def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
self.save2()

def save(self):
with open("grouptextinput.txt", "w") as fobj:
fobj.write(str(self.grouptextinput))
def save2(self):
with open("disabilitytextinput.txt", "w") as fobj:
fobj.write(str(self.disabilitytextinput))
pass

class Help(Screen):
pass

class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
print 'file is opened'
a = myfile.readline(14)
print a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
b = myfile.readline(14)
print b

## a = box.grouptextinput
## b = box.grouptextinput

pass

class ScreenSix(Screen):
pass

class One(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Two(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Three(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Four(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Five(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Six(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Seven(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Eight(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Nine(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

presentation = Builder.load_file("main.kv")

class MainApp(App):



def build(self):
return presentation

if __name__ == "__main__":
MainApp().run()


and this is the kivy code:



#: import FadeTransition kivy.uix.screenmanager.FadeTransition

ScreenManagement:
transition: FadeTransition()
A:
B:
C:
ScreenFour:
Help:
ScreenFive:
ScreenSix:
One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
Nine:

<A>:
name: "llll"
Button:
on_release: app.root.current = "iiii"
Image:
source: '************'
center_x: self.parent.center_x
center_y: self.parent.center_y

<Intentions>:
name: "iiii"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "pppp"
pos: 590,50
size: 200, 60

<Picot>:
name: "pppp"
Image:
source: '****************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFour>
name: "screenfour"
group_text_input: group
disability_text_input: disability
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: "**********"
font_size: '47sp'
pos: 0, 100
color: 0,0,0,1
bold: True

TextInput:
id: group
multiline: False
size_hint_x: .3
size_hint_y: .1
hint_text: '************'
pos: 90, 220
font_size: '29sp'

Label:
text:"********"
font_size: '40sp'
pos: 0, -50
color: 0,0,0,1
bold: True

TextInput:
id: disability
multiline: True
size_hint_x: .3
size_hint_y: .1
hint_text: '*********'
pos: 465, 220
font_size: '29sp'

Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfive"
on_release: root.submit_textinput()
pos: 590,50
size: 200, 60

Button:
text: 'Help!'
id: button
font_size: 30
size_hint: None, None
on_release: app.root.current = "help"
pos: 50,50
size: 100, 60

<Help>
name: "help"
Image:
source: '******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: '*********'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFive>
name:"screenfive"
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: '********'
font_size: '60sp'
pos: 0, 150
color: 0,0,0,1
bold: True

Label:
text: '**********'
font_size: '53sp'
pos: 0, 75
color: 0,0,0,1
bold: True

Label:
text: '*******'
font_size: '60sp'
pos: 0, 0
color: 0,0,0,1
bold: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size: 760, 100
size_hint: None, None
pos: 20,150
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1

Button:
text: 'Continue'
id: button
font_size: 40
size: 200, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 590,50

<ScreenSix>
name: "menu"
canvas:
Color:
rgb: .5, .5, .5
Rectangle:
size: self.size

GridLayout:
cols: 3
spacing: 20
padding: [20,50]
Label:
text: ''
Label:
text: '************'
font_size: '19sp'
Label:
text: ''
Button:
text: '********'
#on_press: root.manager.current = 'settings'
on_release: app.root.current = "one"
Button:
text: '*******'
on_release: app.root.current = "two"
Button:
text: '*****'
on_release: app.root.current = "three"
Button:
text: '********'
on_release: app.root.current = "four"
Button:
text: '********'
on_release: app.root.current = "five"
Button:
text: '********'
on_release: app.root.current = "six"
Button:
text: '*******'
on_release: app.root.current = "seven"
Button:
text: '*********'
on_release: app.root.current = "eight"
Button:
text: '***********'
on_release: app.root.current = "nine"

<One>
name: "one"
Image:
source: '********'
y: self.parent.y
x: self.parent.x
allow_stretch: True

Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
allow_stretch: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Two>
name: "two"
Image:
source: '*******'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Three>
name: "three"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Four>
name: "four"
Image:
source: '*************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Five>
name: "five"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Six>
name: "six"
Image:
source: '************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Seven>
name: "seven"
Image:
source: '*******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Eight>
name: "eight"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Nine>
name: "nine"
Image:
source: '***************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80


i am new to python and kivy both and this is the last thing which is holding me up from building my first app.i would be very thankful if someone could help me out.










share|improve this question
























  • The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
    – John Anderson
    Nov 12 at 17:20










  • Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
    – John Anderson
    Nov 12 at 17:22










  • hey john anderson,
    – Yashas A
    Nov 13 at 13:09










  • thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
    – Yashas A
    Nov 13 at 13:10










  • the code runs absolutely fine with just this glitch. my doubt in precise is :
    – Yashas A
    Nov 13 at 13:13













up vote
1
down vote

favorite









up vote
1
down vote

favorite











currently i am storing all the text input by the user in a file.
when i run this code the screenfive buttons text root.a and root.b are the previous entries but not the present textinput entered.



meaning that in the first execution i had input firstname1 and lastname1 on the screen four.in the screen five's button i see with ( with )
because this is the first time the files are created so there is no text in them.



in the second execution i type fistname2 and lastname2 in screen four but when i move to screen five it displays 'firstname1 with firstname1' in the button's text but i am expecting 'firstname2 with lastname2' which was what i entered during the present execution
this is the python code:



 from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scatter import Scatter
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.config import Config
from kivy.base import runTouchApp

from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, NumericProperty, StringProperty


root = FloatLayout()

class ScreenManagement(ScreenManager):
pass

class A(Screen):
pass

class B(Screen):
pass

class C(Screen):
pass

class ScreenFour(Screen):
group_text_input = ObjectProperty()
disability_text_input = ObjectProperty()

grouptextinput = StringProperty('')
disabilitytextinput = StringProperty('')

global grouptextinput, disabilitytextinput

def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
self.save2()

def save(self):
with open("grouptextinput.txt", "w") as fobj:
fobj.write(str(self.grouptextinput))
def save2(self):
with open("disabilitytextinput.txt", "w") as fobj:
fobj.write(str(self.disabilitytextinput))
pass

class Help(Screen):
pass

class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
print 'file is opened'
a = myfile.readline(14)
print a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
b = myfile.readline(14)
print b

## a = box.grouptextinput
## b = box.grouptextinput

pass

class ScreenSix(Screen):
pass

class One(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Two(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Three(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Four(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Five(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Six(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Seven(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Eight(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Nine(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

presentation = Builder.load_file("main.kv")

class MainApp(App):



def build(self):
return presentation

if __name__ == "__main__":
MainApp().run()


and this is the kivy code:



#: import FadeTransition kivy.uix.screenmanager.FadeTransition

ScreenManagement:
transition: FadeTransition()
A:
B:
C:
ScreenFour:
Help:
ScreenFive:
ScreenSix:
One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
Nine:

<A>:
name: "llll"
Button:
on_release: app.root.current = "iiii"
Image:
source: '************'
center_x: self.parent.center_x
center_y: self.parent.center_y

<Intentions>:
name: "iiii"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "pppp"
pos: 590,50
size: 200, 60

<Picot>:
name: "pppp"
Image:
source: '****************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFour>
name: "screenfour"
group_text_input: group
disability_text_input: disability
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: "**********"
font_size: '47sp'
pos: 0, 100
color: 0,0,0,1
bold: True

TextInput:
id: group
multiline: False
size_hint_x: .3
size_hint_y: .1
hint_text: '************'
pos: 90, 220
font_size: '29sp'

Label:
text:"********"
font_size: '40sp'
pos: 0, -50
color: 0,0,0,1
bold: True

TextInput:
id: disability
multiline: True
size_hint_x: .3
size_hint_y: .1
hint_text: '*********'
pos: 465, 220
font_size: '29sp'

Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfive"
on_release: root.submit_textinput()
pos: 590,50
size: 200, 60

Button:
text: 'Help!'
id: button
font_size: 30
size_hint: None, None
on_release: app.root.current = "help"
pos: 50,50
size: 100, 60

<Help>
name: "help"
Image:
source: '******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: '*********'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFive>
name:"screenfive"
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: '********'
font_size: '60sp'
pos: 0, 150
color: 0,0,0,1
bold: True

Label:
text: '**********'
font_size: '53sp'
pos: 0, 75
color: 0,0,0,1
bold: True

Label:
text: '*******'
font_size: '60sp'
pos: 0, 0
color: 0,0,0,1
bold: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size: 760, 100
size_hint: None, None
pos: 20,150
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1

Button:
text: 'Continue'
id: button
font_size: 40
size: 200, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 590,50

<ScreenSix>
name: "menu"
canvas:
Color:
rgb: .5, .5, .5
Rectangle:
size: self.size

GridLayout:
cols: 3
spacing: 20
padding: [20,50]
Label:
text: ''
Label:
text: '************'
font_size: '19sp'
Label:
text: ''
Button:
text: '********'
#on_press: root.manager.current = 'settings'
on_release: app.root.current = "one"
Button:
text: '*******'
on_release: app.root.current = "two"
Button:
text: '*****'
on_release: app.root.current = "three"
Button:
text: '********'
on_release: app.root.current = "four"
Button:
text: '********'
on_release: app.root.current = "five"
Button:
text: '********'
on_release: app.root.current = "six"
Button:
text: '*******'
on_release: app.root.current = "seven"
Button:
text: '*********'
on_release: app.root.current = "eight"
Button:
text: '***********'
on_release: app.root.current = "nine"

<One>
name: "one"
Image:
source: '********'
y: self.parent.y
x: self.parent.x
allow_stretch: True

Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
allow_stretch: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Two>
name: "two"
Image:
source: '*******'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Three>
name: "three"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Four>
name: "four"
Image:
source: '*************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Five>
name: "five"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Six>
name: "six"
Image:
source: '************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Seven>
name: "seven"
Image:
source: '*******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Eight>
name: "eight"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Nine>
name: "nine"
Image:
source: '***************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80


i am new to python and kivy both and this is the last thing which is holding me up from building my first app.i would be very thankful if someone could help me out.










share|improve this question















currently i am storing all the text input by the user in a file.
when i run this code the screenfive buttons text root.a and root.b are the previous entries but not the present textinput entered.



meaning that in the first execution i had input firstname1 and lastname1 on the screen four.in the screen five's button i see with ( with )
because this is the first time the files are created so there is no text in them.



in the second execution i type fistname2 and lastname2 in screen four but when i move to screen five it displays 'firstname1 with firstname1' in the button's text but i am expecting 'firstname2 with lastname2' which was what i entered during the present execution
this is the python code:



 from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scatter import Scatter
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.config import Config
from kivy.base import runTouchApp

from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, NumericProperty, StringProperty


root = FloatLayout()

class ScreenManagement(ScreenManager):
pass

class A(Screen):
pass

class B(Screen):
pass

class C(Screen):
pass

class ScreenFour(Screen):
group_text_input = ObjectProperty()
disability_text_input = ObjectProperty()

grouptextinput = StringProperty('')
disabilitytextinput = StringProperty('')

global grouptextinput, disabilitytextinput

def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
self.save2()

def save(self):
with open("grouptextinput.txt", "w") as fobj:
fobj.write(str(self.grouptextinput))
def save2(self):
with open("disabilitytextinput.txt", "w") as fobj:
fobj.write(str(self.disabilitytextinput))
pass

class Help(Screen):
pass

class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
print 'file is opened'
a = myfile.readline(14)
print a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
b = myfile.readline(14)
print b

## a = box.grouptextinput
## b = box.grouptextinput

pass

class ScreenSix(Screen):
pass

class One(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Two(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Three(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Four(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Five(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Six(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Seven(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Eight(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

class Nine(Screen):
a = StringProperty()
b = StringProperty()


myfile = open('grouptextinput.txt','r')
a = myfile.readline(14)

myfile = open('disabilitytextinput.txt','r')
b = myfile.readline(14)

pass

presentation = Builder.load_file("main.kv")

class MainApp(App):



def build(self):
return presentation

if __name__ == "__main__":
MainApp().run()


and this is the kivy code:



#: import FadeTransition kivy.uix.screenmanager.FadeTransition

ScreenManagement:
transition: FadeTransition()
A:
B:
C:
ScreenFour:
Help:
ScreenFive:
ScreenSix:
One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
Nine:

<A>:
name: "llll"
Button:
on_release: app.root.current = "iiii"
Image:
source: '************'
center_x: self.parent.center_x
center_y: self.parent.center_y

<Intentions>:
name: "iiii"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "pppp"
pos: 590,50
size: 200, 60

<Picot>:
name: "pppp"
Image:
source: '****************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFour>
name: "screenfour"
group_text_input: group
disability_text_input: disability
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: "**********"
font_size: '47sp'
pos: 0, 100
color: 0,0,0,1
bold: True

TextInput:
id: group
multiline: False
size_hint_x: .3
size_hint_y: .1
hint_text: '************'
pos: 90, 220
font_size: '29sp'

Label:
text:"********"
font_size: '40sp'
pos: 0, -50
color: 0,0,0,1
bold: True

TextInput:
id: disability
multiline: True
size_hint_x: .3
size_hint_y: .1
hint_text: '*********'
pos: 465, 220
font_size: '29sp'

Button:
text: 'Next'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfive"
on_release: root.submit_textinput()
pos: 590,50
size: 200, 60

Button:
text: 'Help!'
id: button
font_size: 30
size_hint: None, None
on_release: app.root.current = "help"
pos: 50,50
size: 100, 60

<Help>
name: "help"
Image:
source: '******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: '*********'
id: button
font_size: 40
size_hint: None, None
on_release: app.root.current = "screenfour"
pos: 590,50
size: 200, 60

<ScreenFive>
name:"screenfive"
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: '***************'

Label:
text: '********'
font_size: '60sp'
pos: 0, 150
color: 0,0,0,1
bold: True

Label:
text: '**********'
font_size: '53sp'
pos: 0, 75
color: 0,0,0,1
bold: True

Label:
text: '*******'
font_size: '60sp'
pos: 0, 0
color: 0,0,0,1
bold: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size: 760, 100
size_hint: None, None
pos: 20,150
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1

Button:
text: 'Continue'
id: button
font_size: 40
size: 200, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 590,50

<ScreenSix>
name: "menu"
canvas:
Color:
rgb: .5, .5, .5
Rectangle:
size: self.size

GridLayout:
cols: 3
spacing: 20
padding: [20,50]
Label:
text: ''
Label:
text: '************'
font_size: '19sp'
Label:
text: ''
Button:
text: '********'
#on_press: root.manager.current = 'settings'
on_release: app.root.current = "one"
Button:
text: '*******'
on_release: app.root.current = "two"
Button:
text: '*****'
on_release: app.root.current = "three"
Button:
text: '********'
on_release: app.root.current = "four"
Button:
text: '********'
on_release: app.root.current = "five"
Button:
text: '********'
on_release: app.root.current = "six"
Button:
text: '*******'
on_release: app.root.current = "seven"
Button:
text: '*********'
on_release: app.root.current = "eight"
Button:
text: '***********'
on_release: app.root.current = "nine"

<One>
name: "one"
Image:
source: '********'
y: self.parent.y
x: self.parent.x
allow_stretch: True

Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
allow_stretch: True

Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Two>
name: "two"
Image:
source: '*******'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Three>
name: "three"
Image:
source: '***********'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Four>
name: "four"
Image:
source: '*************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Five>
name: "five"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Six>
name: "six"
Image:
source: '************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Seven>
name: "seven"
Image:
source: '*******************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Eight>
name: "eight"
Image:
source: '********************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80

<Nine>
name: "nine"
Image:
source: '***************'
y: self.parent.y
x: self.parent.x
allow_stretch: True
size: 800, 750
Button:
text: 'Back To Menu'
id: button
font_size: 40
size: 300, 60
size_hint: None, None
on_release: app.root.current = "menu"
pos: 100,13
Button:
text: root.a + ' WITH ' + root.b
font_size: 40
text_size: self.width, None
size_hint: None, None
halign: 'center'
background_color: (0, 0, 0, 1)
color: 1, 1, 1, 1
pos: 0,520
size: 800, 80


i am new to python and kivy both and this is the last thing which is holding me up from building my first app.i would be very thankful if someone could help me out.







python kivy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 13:09

























asked Nov 12 at 13:06









Yashas A

63




63












  • The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
    – John Anderson
    Nov 12 at 17:20










  • Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
    – John Anderson
    Nov 12 at 17:22










  • hey john anderson,
    – Yashas A
    Nov 13 at 13:09










  • thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
    – Yashas A
    Nov 13 at 13:10










  • the code runs absolutely fine with just this glitch. my doubt in precise is :
    – Yashas A
    Nov 13 at 13:13


















  • The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
    – John Anderson
    Nov 12 at 17:20










  • Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
    – John Anderson
    Nov 12 at 17:22










  • hey john anderson,
    – Yashas A
    Nov 13 at 13:09










  • thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
    – Yashas A
    Nov 13 at 13:10










  • the code runs absolutely fine with just this glitch. my doubt in precise is :
    – Yashas A
    Nov 13 at 13:13
















The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
– John Anderson
Nov 12 at 17:20




The text for your Button in ScreenFive is root.a + ' with ' + root.b. The values of root.a and root.b are set by reading your files when you start the App, and you have not implemented any other way for root.a and root.b to be updated, so they will not change.
– John Anderson
Nov 12 at 17:20












Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
– John Anderson
Nov 12 at 17:22




Also, you code above is not a MCVE. In fact, it won't even run. Please update the code in your question to make a MCVE.
– John Anderson
Nov 12 at 17:22












hey john anderson,
– Yashas A
Nov 13 at 13:09




hey john anderson,
– Yashas A
Nov 13 at 13:09












thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
– Yashas A
Nov 13 at 13:10




thanks for your attention, i have updated the code please have a look at it. looking forward for a reply.
– Yashas A
Nov 13 at 13:10












the code runs absolutely fine with just this glitch. my doubt in precise is :
– Yashas A
Nov 13 at 13:13




the code runs absolutely fine with just this glitch. my doubt in precise is :
– Yashas A
Nov 13 at 13:13












1 Answer
1






active

oldest

votes

















up vote
0
down vote













First, some problems with your code. In every case where you have:



a = StringProperty()
b = StringProperty()


in your class definition, you follow it with:



a = myfile.readline(14)


and



b = myfile.readline(14)


That replaces your StringProperty with an ordinary String, and so eliminates the link with references like root.a and root.b in the kv file.



In order to get this to work, I changed your definition of ScreenFive to:



class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()

def __init__(self, **kwargs):
super(ScreenFive, self).__init__(**kwargs)

myfile = open('grouptextinput.txt','r')
print 'file is opened'
self.a = myfile.readline(14)
print self.a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
self.b = myfile.readline(14)
print self.b


The above keeps a and b as StringProperty and allows the kv bindings to work. The next step is to update a and b in ScreenFive when you want the values to change. To do this, I modified your submit_textinput method in ScreenFour as:



def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput
self.save2()


The lines:



App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput


and:



App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput


update the StringProperty values in ScreenFive.



I also changed your MainApp:



class MainApp(App):

def build(self):
self.sm = presentation
return presentation


to keep a reference to the ScreenManager.






share|improve this answer





















  • thanks a lot. it works all fine. very greatful
    – Yashas A
    Nov 14 at 14:10











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262828%2fi-want-to-use-text-entered-by-the-user-on-one-screen-in-other-screens-too-as-a-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













First, some problems with your code. In every case where you have:



a = StringProperty()
b = StringProperty()


in your class definition, you follow it with:



a = myfile.readline(14)


and



b = myfile.readline(14)


That replaces your StringProperty with an ordinary String, and so eliminates the link with references like root.a and root.b in the kv file.



In order to get this to work, I changed your definition of ScreenFive to:



class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()

def __init__(self, **kwargs):
super(ScreenFive, self).__init__(**kwargs)

myfile = open('grouptextinput.txt','r')
print 'file is opened'
self.a = myfile.readline(14)
print self.a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
self.b = myfile.readline(14)
print self.b


The above keeps a and b as StringProperty and allows the kv bindings to work. The next step is to update a and b in ScreenFive when you want the values to change. To do this, I modified your submit_textinput method in ScreenFour as:



def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput
self.save2()


The lines:



App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput


and:



App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput


update the StringProperty values in ScreenFive.



I also changed your MainApp:



class MainApp(App):

def build(self):
self.sm = presentation
return presentation


to keep a reference to the ScreenManager.






share|improve this answer





















  • thanks a lot. it works all fine. very greatful
    – Yashas A
    Nov 14 at 14:10















up vote
0
down vote













First, some problems with your code. In every case where you have:



a = StringProperty()
b = StringProperty()


in your class definition, you follow it with:



a = myfile.readline(14)


and



b = myfile.readline(14)


That replaces your StringProperty with an ordinary String, and so eliminates the link with references like root.a and root.b in the kv file.



In order to get this to work, I changed your definition of ScreenFive to:



class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()

def __init__(self, **kwargs):
super(ScreenFive, self).__init__(**kwargs)

myfile = open('grouptextinput.txt','r')
print 'file is opened'
self.a = myfile.readline(14)
print self.a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
self.b = myfile.readline(14)
print self.b


The above keeps a and b as StringProperty and allows the kv bindings to work. The next step is to update a and b in ScreenFive when you want the values to change. To do this, I modified your submit_textinput method in ScreenFour as:



def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput
self.save2()


The lines:



App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput


and:



App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput


update the StringProperty values in ScreenFive.



I also changed your MainApp:



class MainApp(App):

def build(self):
self.sm = presentation
return presentation


to keep a reference to the ScreenManager.






share|improve this answer





















  • thanks a lot. it works all fine. very greatful
    – Yashas A
    Nov 14 at 14:10













up vote
0
down vote










up vote
0
down vote









First, some problems with your code. In every case where you have:



a = StringProperty()
b = StringProperty()


in your class definition, you follow it with:



a = myfile.readline(14)


and



b = myfile.readline(14)


That replaces your StringProperty with an ordinary String, and so eliminates the link with references like root.a and root.b in the kv file.



In order to get this to work, I changed your definition of ScreenFive to:



class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()

def __init__(self, **kwargs):
super(ScreenFive, self).__init__(**kwargs)

myfile = open('grouptextinput.txt','r')
print 'file is opened'
self.a = myfile.readline(14)
print self.a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
self.b = myfile.readline(14)
print self.b


The above keeps a and b as StringProperty and allows the kv bindings to work. The next step is to update a and b in ScreenFive when you want the values to change. To do this, I modified your submit_textinput method in ScreenFour as:



def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput
self.save2()


The lines:



App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput


and:



App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput


update the StringProperty values in ScreenFive.



I also changed your MainApp:



class MainApp(App):

def build(self):
self.sm = presentation
return presentation


to keep a reference to the ScreenManager.






share|improve this answer












First, some problems with your code. In every case where you have:



a = StringProperty()
b = StringProperty()


in your class definition, you follow it with:



a = myfile.readline(14)


and



b = myfile.readline(14)


That replaces your StringProperty with an ordinary String, and so eliminates the link with references like root.a and root.b in the kv file.



In order to get this to work, I changed your definition of ScreenFive to:



class ScreenFive(Screen):
box = ScreenFour()
a = StringProperty()
b = StringProperty()

def __init__(self, **kwargs):
super(ScreenFive, self).__init__(**kwargs)

myfile = open('grouptextinput.txt','r')
print 'file is opened'
self.a = myfile.readline(14)
print self.a

myfile = open('disabilitytextinput.txt','r')
print 'file is opened'
self.b = myfile.readline(14)
print self.b


The above keeps a and b as StringProperty and allows the kv bindings to work. The next step is to update a and b in ScreenFive when you want the values to change. To do this, I modified your submit_textinput method in ScreenFour as:



def submit_textinput(self):
self.grouptextinput = self.group_text_input.text
print("group of people: {}".format(self.grouptextinput))
App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput
self.save()

self.disabilitytextinput = self.disability_text_input.text
print("with following disability: {}".format(self.disabilitytextinput))
App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput
self.save2()


The lines:



App.get_running_app().sm.get_screen("screenfive").a = self.grouptextinput


and:



App.get_running_app().sm.get_screen("screenfive").b = self.disabilitytextinput


update the StringProperty values in ScreenFive.



I also changed your MainApp:



class MainApp(App):

def build(self):
self.sm = presentation
return presentation


to keep a reference to the ScreenManager.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 at 20:56









John Anderson

2,0581312




2,0581312












  • thanks a lot. it works all fine. very greatful
    – Yashas A
    Nov 14 at 14:10


















  • thanks a lot. it works all fine. very greatful
    – Yashas A
    Nov 14 at 14:10
















thanks a lot. it works all fine. very greatful
– Yashas A
Nov 14 at 14:10




thanks a lot. it works all fine. very greatful
– Yashas A
Nov 14 at 14:10


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262828%2fi-want-to-use-text-entered-by-the-user-on-one-screen-in-other-screens-too-as-a-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?