Reputation: 3
So I'm working on a kivy project and also learning the language for it (I mean python) and I have this little program here. So there are some language button on my first screen but I also have text to change in the second page. How can I call an other class' function in a class, or should I use a different way to change the textes? Any tipp would be helpful :) thanks
class ScreenOne(Screen):
def d_language(self):
self.hellolabel.text='Hallo'
def fr_language(self):
self.hellolabel.text='Bonjour'
class ScreenTwo(Screen):
def d_languagetwo(self):
self.otherlabel.text='Zweite seite'
def fr_languagetwo(self):
self.otherlabel.text='Deuxième page'
Upvotes: 0
Views: 2285
Reputation: 8066
You can use the screen manager to get to the other screen
def d_language(self):
self.hellolabel.text = 'Hallo'
#now change the other label
s2 = self.manager.get_screen('name of the other screen')
#or ...
#s2 = self.manager.screens[1] # will also work...
s2.otherlabel.text = 'Zweite seite'
#or ...
#s2.d_languagetwo()
...
Upvotes: 2