How can you pass a complex object into a kv file? - python

I have a game I am building and the whole game logic is contained in a Game() class. I would like to pass an object of this game into the kv file. Here is my code:
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivy.uix.screenmanager import Screen, ScreenManager
class Game():
name = "Game Name"
def __init__(self, player):
self.player = player
build = """
WindowManager:
HomeScreen:
<HomeScreen>:
name: 'home'
BoxLayout:
orientation: 'horizontal'
size: root.width, root.height
Button:
text: "New Game"
on_release:
app.root.load_game("player")
app.root.current = 'game'
<GameScreen>:
name: 'game'
BoxLayout:
orientation: 'horizontal'
Label:
text: root.game.name
"""
class HomeScreen(Screen):
pass
class GameScreen(Screen):
player = StringProperty()
def __init__(self, player, **kw):
super().__init__(**kw)
self.player = player
self.game = Game(self.player)
class WindowManager(ScreenManager):
def load_game(self, player):
self.add_widget(GameScreen(player))
class Application(App):
def build(self):
return Builder.load_string(build)
if __name__ == '__main__':
Application().run()
This runs, but when I try to click the button to instantiate the game screen it throws an error saying that the GameScreen doesn't have a "game" property. There isn't, as far as I'm aware, a ClassProperty property in Kivy, how would I pass in an object that's not a primitive type?

To add an object as a property:
from kivy.properties import StringProperty, ObjectProperty # Import ObjectProperty
class GameScreen(Screen):
player = StringProperty()
game = ObjectProperty(Game) #Add an object property

Related

How to make a variable in python that can be accessed and modified by any screens in kivy?

I want to make a variable that can be modified by one screen, then the variable can change the text of different screen.
Here is the python file
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen,ScreenManager
from kivy.properties import NumericProperty
import random
value = NumericProperty(0)
class MainWindow(Screen):
def vval(self, root):
root.value = 1
def vvval(self, root):
root.value = 2
class SecondWindow(Screen):
pass
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("testing.kv")
class testing(App):
def build(self):
return kv
if __name__ == "__main__":
testing().run()
and here is the kivy file
WindowManager:
MainWindow:
SecondWindow:
<MainWindow>:
name: "main"
GridLayout:
size: root.width, root.height
rows: 2
Button:
text: "print 1"
on_release:
root.vval(root)
app.root.current = "second"
Button:
text: "print 2"
on_release:
root.vvval(root)
app.root.current = "second"
<SecondWindow>:
name: "second"
Label:
text: "successfully printed ", root.value
What I expected to happens is when I click one of the button in the the MainWindow, the variable, which I named it "value" will be modified to 1 or 2 depending on what button i click, then the screen changed to the SecondWindow and display the text "successfully printed x", the value of x is depends to the "value" variable.
I'm still new on kivy, if there is some error or ambiguity, I am sorry. Please share me your knowledge about this, it will be appreciated.
Generally, one would do this with a StringProperty object. The code below shows a working example, although I did take liberties in restructuring some things about your code. I admit I had some challenges with .bind of the StringProperty which I ended up resolving by building the ScreenManager object in the Python code instead of the .kv lines.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.properties import NumericProperty, StringProperty
value = NumericProperty(0)
Builder.load_string('''
<MainWindow>
name: "main"
GridLayout:
size: root.width, root.height
rows: 2
Button:
text: "print 1"
on_release:
# arguments can be passed, including a 'self' of the button object
app.kv_button("1", "second", self)
# app.root.current = "second"
Button:
text: "print 2"
on_release:
# arguments can be passed, including a 'self' of the button object
app.kv_button("2", "second", self)
# app.root.current = "second"
<SecondWindow>
name: "second"
Label:
# maps to a StringProperty, root. would be the widget, this is app. which is the App()
text: app.result_text
''')
class MainWindow(Screen):
pass
class SecondWindow(Screen):
value: str
pass
class WindowManager(ScreenManager):
pass
# Builder.load_file("testing.kv")
class testing(App):
result_text = StringProperty()
def kv_button(self, _value: str, next_screen: str, *args):
print(f"{self} {_value} {args}")
self.result_text = _value
# change the screen using the WindowManager object that has been kept as a reference
self._main.current=next_screen
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._main = WindowManager()
self._main.add_widget(MainWindow())
self._main.add_widget(SecondWindow())
def build(self):
return self._main
if __name__ == "__main__":
testing().run()

Error Code : "KivyMD: App object must be initialized before loading "

I am receiving the Error : "KivyMD: App object must be initialized before loading " when I am trying to add a kivymd button (MDRaisedButton).
I tried debugging, the issue is when I add the BoxLayout under the DateScreen, I just don't find any information on how to fix it.
How should one initialized app object before loading ?
import kivy
kivy.require("1.11.1")
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.uix.screenmanager import Screen
from kivymd.theming import ThemeManager
class WelcomeScreen(Screen): # Defines WelcomeScreen instance as a screen widget.
pass
class DateScreen(Screen): # Defines DateScreen instance as a screen widget.
pass
class ResultScreen(Screen): # Defines ResultScreen instance as a screen widget.
pass
root_widget = Builder.load_string("""
ScreenManager:
WelcomeScreen:
DateScreen:
ResultScreen:
<WelcomeScreen>:
_welcome_screen_text_: welcome_screen
name: 'my_welcome_screen'
Label:
id: welcome_screen
Image:
source: 'Cheers.jpg'
size: 200, 200
center: self.parent.center
<DateScreen>:
_date_screen_text_: date_screen
name: 'my_date_screen'
Label:
id: date_screen
text: "This is the date selection screen"
BoxLayout:
size_hint: 0.1, 0.5
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
MDRaisedButton:
text: 'MDButton1'
<ResultScreen>:
_result_screen_text_: result_screen
name: 'my_result_screen'
Label:
id: result_screen
text: "This is where the result will be displayed"
""")
class MainApp(App):
theme_cls = ThemeManager()
def build(self):
self.theme_cls.theme_style = "Dark"
Clock.schedule_once(self.screen_switch_one, 36) # clock callback for the first screen
Clock.schedule_once(self.screen_switch_two, 4) # clock callback for the second screen
return root_widget
def screen_switch_one(a, b):
root_widget.current = 'my_welcome_screen'
def screen_switch_two(a, b):
root_widget.current = 'my_date_screen'
if __name__ == '__main__':
MainApp().run()
Please help!
I believe you need to call Builder after the App is initialized (as mentioned in your error). To do that you can save your kv in a string, then call Builder inside the build() method. Like this:
import kivy
from kivymd.app import MDApp
kivy.require("1.11.1")
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.uix.screenmanager import Screen
class WelcomeScreen(Screen): # Defines WelcomeScreen instance as a screen widget.
pass
class DateScreen(Screen): # Defines DateScreen instance as a screen widget.
pass
class ResultScreen(Screen): # Defines ResultScreen instance as a screen widget.
pass
kv = """
ScreenManager:
WelcomeScreen:
DateScreen:
ResultScreen:
<WelcomeScreen>:
_welcome_screen_text_: welcome_screen
name: 'my_welcome_screen'
Label:
id: welcome_screen
Image:
source: 'Cheers.jpg'
size: 200, 200
center: self.parent.center
<DateScreen>:
_date_screen_text_: date_screen
name: 'my_date_screen'
Label:
id: date_screen
text: "This is the date selection screen"
BoxLayout:
size_hint: 0.1, 0.5
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
MDRaisedButton:
text: 'MDButton1'
<ResultScreen>:
_result_screen_text_: result_screen
name: 'my_result_screen'
Label:
id: result_screen
text: "This is where the result will be displayed"
"""
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.root_widget = Builder.load_string(kv)
Clock.schedule_once(self.screen_switch_one, 36) # clock callback for the first screen
Clock.schedule_once(self.screen_switch_two, 4) # clock callback for the second screen
return self.root_widget
def screen_switch_one(self, dt):
self.root_widget.current = 'my_welcome_screen'
def screen_switch_two(self, dt):
self.root_widget.current = 'my_date_screen'
if __name__ == '__main__':
MainApp().run()

How to change counter variable from a different class and show on kivy screen python

Please Help me with this new problem.
I want to increment the variable Num of ScreenOne Class from different class ScreenTwo by it's Function Increment.
from kivymd.app import MDApp
from kivmob import TestIds ,RewardedListenerInterface,AdMobRewardedVideoAdListener ,KivMob
from kivymd.theming import ThemeManager
from kivy.uix.screenmanager import Screen,ScreenManager
from kivy.lang.builder import Builder
from kivy.uix.label import Label
from kivy.properties import NumericProperty
class Screen_Manager(ScreenManager):
pass
class ScreenOne(Screen):
Num = NumericProperty(0)
def Increase(self):
ScreenTwo().Increase()
class ScreenTwo(ScreenOne):
def Increase(self):
ScreenOne.Num +=1
Builder.load_string("""
#.import MDRaisedButton kivymd.uix.button.MDRaisedButton
<Screen_Manager>:
ScreenOne:
<ScreenOne>:
name:"One"
Label:
text:"Number "+str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
""")
class TestApp(MDApp):
def __init__(self,**kwargs):
self.theme_cls.theme_style = "Dark"
super().__init__(**kwargs)
def build(self):
return Screen_Manager()
if __name__ == "__main__":
TestApp().run()
This code gives me error
TypeError: unsupported operand type(s) for +=: 'kivy.properties.NumericProperty' and 'int'
Please Find me a way to increment the Num variable from class ScreenTwo.
and the condition is that it must show on Kivy Screen
Any Help will be Appreciated.
Please Help !!
I assigned id to ScreenManager and added this manager to every Screen
<Screen_Manager>:
id: screen_manager
ScreenOne:
id: one
name: "One"
manager: screen_manager
ScreenTwo:
id: two
name:"Two"
manager: screen_manager
This way I can access other window using manager and id of other screen.
class ScreenOne(Screen):
Num = NumericProperty(0)
def Increase(self):
# change in current Screen - ScreenOne
self.Num += 1
print('One:', self.Num)
# change in other Screen - ScreenTwo
self.manager.ids.two.Num += 2
print('Two:', self.manager.ids.two.Num)
# or
#self.manager.ids.two.Increase()
Full working code which changes Num in other screen and with buttons to see other screens.
from kivymd.app import MDApp
from kivymd.theming import ThemeManager
#from kivmob import TestIds, RewardedListenerInterface, AdMobRewardedVideoAdListener, KivMob
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang.builder import Builder
from kivy.uix.label import Label
from kivy.properties import NumericProperty
class Screen_Manager(ScreenManager):
pass
class ScreenOne(Screen):
Num = NumericProperty(0)
def Increase(self):
# change in current Screen - ScreenOne
self.Num += 1
print('One:', self.Num)
# change in other Screen - ScreenTwo
#self.manager.ids.two.Num += 2
#print('Two:', self.manager.ids.two.Num)
# or
self.manager.ids.two.Increase()
class ScreenTwo(ScreenOne):
def Increase(self):
# change in current Screen - ScreenTwo
self.Num += 2
print('Two:', self.Num)
Builder.load_string("""
#.import MDRaisedButton kivymd.uix.button.MDRaisedButton
<Screen_Manager>:
id: screen_manager
ScreenOne:
id: one
name: "One"
manager: screen_manager
ScreenTwo:
id: two
name:"Two"
manager: screen_manager
<ScreenOne>:
Label:
id: lb1
text: "Number " + str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
MDRaisedButton:
text: "Go To Screen Two"
pos_hint:{"center_x":0.5,"top":0.1}
on_release:
root.manager.current = 'Two'
<ScreenTwo>:
Label:
id: lb2
text: "Number " + str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
MDRaisedButton:
text: "Go To Screen One"
pos_hint:{"center_x":0.5,"top":0.1}
on_release:
root.manager.current = 'One'
""")
class TestApp(MDApp):
def __init__(self,**kwargs):
self.theme_cls.theme_style = "Dark"
super().__init__(**kwargs)
def build(self):
return Screen_Manager()
if __name__ == "__main__":
TestApp().run()
EDIT: it seems you don't have to assign screen_manager to manager because it has already built-in manager (or you can use built-in parent)
# using `id
#self.parent.ids.two.Increase()
self.manager.ids.two.Increase()
# using `name`
#self.parent.get_screen('Two').Increase()
self.manager.get_screen('Two').Increase()
Using id you have to set ids in Screen_Manager, not in Screen
<Screen_Manager>:
ScreenOne:
id: one
ScreenTwo:
id: two
But using name you can set names in Screen_Manager or in Screen
from kivymd.app import MDApp
from kivymd.theming import ThemeManager
#from kivmob import TestIds, RewardedListenerInterface, AdMobRewardedVideoAdListener, KivMob
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang.builder import Builder
from kivy.uix.label import Label
from kivy.properties import NumericProperty
class Screen_Manager(ScreenManager):
pass
class ScreenOne(Screen):
Num = NumericProperty(0)
def Increase(self):
# change in current Screen - ScreenOne
self.Num += 1
print('One:', self.Num)
# change in other Screen - ScreenTwo
# using `id`
#self.parent.ids.two.Num += 2
#self.parent.ids.two.Increase()
#self.manager.ids.two.Num += 2
#self.manager.ids.two.Increase()
#print('Two:', self.manager.ids.two.Num)
# using `name`
#self.parent.get_screen('Two').Num += 2
#self.parent.get_screen('Two').Increase()
#self.manager.get_screen('Two').Num += 2
self.manager.get_screen('Two').Increase()
class ScreenTwo(ScreenOne):
def Increase(self):
# change in current Screen - ScreenTwo
self.Num += 2
print('Two:', self.Num)
Builder.load_string("""
#.import MDRaisedButton kivymd.uix.button.MDRaisedButton
<Screen_Manager>:
ScreenOne:
id: one
ScreenTwo:
id: two
<ScreenOne>:
name: "One"
other: "Two"
Label:
id: lb1
text: "Number " + str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
MDRaisedButton:
text: "Go To Screen " + root.other
pos_hint:{"center_x":0.5,"top":0.1}
on_release:
root.manager.current = root.other
<ScreenTwo>:
name: "Two"
other: "One"
Label:
id: lb2
text: "Number " + str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
MDRaisedButton:
text: "Go To Screen " + root.other
pos_hint:{"center_x":0.5,"top":0.1}
on_release:
root.manager.current = root.other
""")
class TestApp(MDApp):
def __init__(self,**kwargs):
self.theme_cls.theme_style = "Dark"
super().__init__(**kwargs)
def build(self):
return Screen_Manager()
if __name__ == "__main__":
TestApp().run()
BTW: you can use manager or parent to set some value(s) in ScreenManager and share it with all Screens.
EDIT:
Using inheritance
class ScreenTwo(ScreenOne):
was missleading.
if ScreenTwo is not a Screen then you can create it without inheritance
class ScreenTwo():
And create it in ScreenOne.__init__. And send ScreenOne (self) to ScreenTwo so ScreenTwo will have access to variables in ScreenOne
class ScreenOne(Screen):
Num = NumericProperty(0)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.second = ScreenTwo(self) # create instance of `ScreenTwo` and send `ScreenOne` (self) as argument
def Increase(self):
self.second.Increase() # run `Increase()` from `ScreenTwo`
class ScreenTwo():
def __init__(self, other):
self.first = other # keep access to `ScreenOne`
def Increase(self):
self.first.Num +=1 # change `Num` in `ScreanOne`
Full example
from kivymd.app import MDApp
from kivymd.theming import ThemeManager
#from kivmob import TestIds, RewardedListenerInterface, AdMobRewardedVideoAdListener, KivMob
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang.builder import Builder
from kivy.uix.label import Label
from kivy.properties import NumericProperty
class Screen_Manager(ScreenManager):
pass
class ScreenOne(Screen):
Num = NumericProperty(0)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.second = ScreenTwo(self) # create instance of `ScreenTwo` and send `ScreenOne` (self) as argument
def Increase(self):
self.second.Increase() # run `Increase()` from `ScreenTwo`
class ScreenTwo():
def __init__(self, other):
self.first = other # keep access to `ScreenOne`
def Increase(self):
self.first.Num +=1 # change `Num` in `ScreanOne`
Builder.load_string("""
#.import MDRaisedButton kivymd.uix.button.MDRaisedButton
<Screen_Manager>:
ScreenOne:
<ScreenOne>:
name: "One"
Label:
id: lb1
text: "Number " + str(root.Num)
pos_hint:{"center_x":0.5,"top":0.7}
MDRaisedButton:
text:"Click here"
pos_hint:{"center_x":0.5,"top":0.6}
on_release:
root.Increase()
""")
class TestApp(MDApp):
def __init__(self,**kwargs):
self.theme_cls.theme_style = "Dark"
super().__init__(**kwargs)
def build(self):
return Screen_Manager()
if __name__ == "__main__":
TestApp().run()

How can I print the position of the pointer every time the mouse is moved over a widget in kivy?

I want to print out the position of the pointer (mouse) everytime it passes over a widget. Actually to be more specific I'd like to print the current position of the mouse everytime it moves. Is that at all possible?
Right now all I've managed to do is:
Print the position of the mouse whenever the mouse is clicked
(in two different ways)
Print the position of the widget when it's clicked
I'm sure it's easier than I think, thanks in advance.
from kivy.core.window import Window
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.input.motionevent import MotionEvent
class MainScreen(Screen):
def __init__(self, **kwargs):
super(MainScreen, self).__init__(**kwargs)
def on_mouse_pos(self, pos):
if Window.mouse_pos == self.ids.example_button:
print("You've made it")
# With out this if statement it does print the position every time
# That the mouse is moved. But can I print "You've made it" every time
# that the mouse is moved over the position of a widget?
print(pos)
def test_print(self):
print(str(self.ids.example_button.pos))
Window.bind(mouse_pos = on_mouse_pos)
class MyScreenManager(Screen):
pass
root_widget = Builder.load_string('''
MyScreenManager:
MainScreen:
<MainScreen>:
name: 'Example'
Button:
id: example_button
text: 'Print position of widget when mouse touches it'
size_hint: 1, .05
pos_hint: {'x': 0, 'y': .5}
on_release: root.test_print()
''')
class TestApp(App):
def build(self):
self.title = 'Example Application'
return root_widget
if __name__ == '__main__':
TestApp().run()
A possible solution is to use mouse_pos:
from kivy.core.window import Window
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class MainScreen(Screen):
def on_mouse_pos(self, pos):
print(pos)
Window.bind(mouse_pos = on_mouse_pos)
class MyScreenManager(Screen):
pass
root_widget = Builder.load_string('''
MyScreenManager:
MainScreen:
<MainScreen>:
name: 'Example'
Button:
id: example_button
text: 'I am button'
size_hint: 1, .05
pos_hint: {'x': 0, 'y': .5}
''')
class TestApp(App):
def build(self):
self.title = 'Example Application'
return root_widget
if __name__ == '__main__':
TestApp().run()
Update:
If you want to verify that the mouse point is inside a widget you must use collide_point.
from kivy.core.window import Window
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class MainScreen(Screen):
def __init__(self, **kwargs):
super(MainScreen, self).__init__(**kwargs)
Window.bind(mouse_pos = self.on_mouse_pos)
def on_mouse_pos(self, instance, pos):
if self.ids.example_button.collide_point(*pos):
print("You've made it")
class MyScreenManager(Screen):
pass
root_widget = Builder.load_string('''
MyScreenManager:
MainScreen:
<MainScreen>:
name: 'Example'
Button:
id: example_button
text: 'I am button'
size_hint: 1, .05
pos_hint: {'x': 0, 'y': .5}
''')
class TestApp(App):
def build(self):
self.title = 'Example Application'
return root_widget
if __name__ == '__main__':
TestApp().run()

Changing variables from one screen to other using python in kivy

I have a two screen kivy app and I want to pass a variable from one screen to a second screen using python.
python file
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import StringProperty,ObjectProperty
from kivy.uix.label import Label
class MenuScreen(Screen):
label1=StringProperty()
label2=StringProperty()
def __init__(self,**kwargs):
super(MenuScreen, self).__init__(**kwargs)
self.label1="hello"
self.label2="world"
def change_text(self):
lbl1=self.label1+ " and "
lbl2= "A beautiful "+self.label2
chg=SettingsScreen()
chg.UpdateSettings(lbl1,lbl2)
# HERE: something like
class SettingsScreen(Screen):
label3=StringProperty()
label4=StringProperty()
def __init__(self,**kwargs):
super(SettingsScreen, self).__init__(**kwargs)
#some default texts
self.label3="Nothing"
self.label4="Nothing"
def UpdateSettings(self,lbl1,lbl2):
print(lbl1,lbl2)
self.label3=lbl1
self.label4=lbl2
class TestScreenManager(ScreenManager):
menu_screen=ObjectProperty(None)
settings_screen=ObjectProperty(None)
class TestApp(App):
def build(self):
return TestScreenManager()
TestApp().run()
kvfile
#: import ScreenManager kivy.uix.screenmanager.ScreenManager
#: import Screen kivy.uix.screenmanager.ScreenManager
#: import SettingsScreen screen
<TestScreenManager>:
id: screen_manager
menu_screen: menu_screen
settings_screen: settings_screen
MenuScreen:
id: menu_screen
name: 'menu'
manager: screen_manager
SettingsScreen:
id: settings_screen
name: 'settings_screen'
manager: screen_manager
<MenuScreen>:
name: 'MenuScreen'
BoxLayout:
Label:
text:root.label1
Label:
text:root.label2
Button:
text: 'Goto nn'
size_hint_y:0.2
on_press:
root.manager.current = 'settings_screen'
root.change_text()
<SettingsScreen>:
#name: 'SettingsScreen'
label_id: label_field
BoxLayout:
Label:
text:root.label3
Label:
text:root.label4
Label:
id: label_field
text: "some text"
It runs without an error but it is not changing the variables of the second screen. For debugging I added print(lbl1,lbl2) inside UpdateSetting functions and it prints out passing lbl1 and lbl2 variables but its not updating the labels.
When you do chg=SettingsScreen(), you are creating a new instance of the SettingsScreen class and you modify the labels of that instance. You need to access the object used by your ScreenManager, not create a new one.
You can use the manager property of your current Screen to get the instance reference of the other screen:
def change_text(self):
lbl1=self.label1 + " and "
lbl2= "A beautiful "+ self.label2
chg = self.manager.settings_screen #<<<<<<<<<<<<<<
chg.UpdateSettings(lbl1,lbl2)

Categories