Enter code here...
class WelcomeScreen(Screen): #welcomeScreen subclass
def __init__(self, **kwargs): #constructor method
super(WelcomeScreen, self).__init__(**kwargs)
welcomePage = FloatLayout()
box = BoxLayout(orientation='vertical', size_hint=(0.4, 0.3),
padding=8, pos_hint={'top': 0.5, 'center_x': 0.5})
self.cameraObject = Camera(play=False) ## WANT TO USE THIS VARIABLE IN OTHER CLASS
self.cameraObject.play = True
self.cameraObject.resolution = (700, 400)
self.add_widget(self.cameraObject)
class FunctionScreen(Screen):
def __init__(self, **kwargs):
super(FunctionScreen, self).__init__(**kwargs) #init parent
functionPage = FloatLayout()
functionLabel = Label(text='what functions to use',
halign='center', valign='center', size_hint=(0.4,0.2), pos_hint={'top': 1, 'center_x': 0.5})
self.img = self.cameraObject ## HERE I WANT TO USE 'self.cameraObject' VARIABLE
I assume these 2 screens are attached to the same screen manager.
Inside a screen, self.manager refers the screenmanager.
self.manager.get_scereen(‘screen_name’) refers to the screen. I’ll assume you are setting the screen name in your kv code. I’ll use ‘welcome_screen’ as the name.
self.manager.get_screen(‘welcome_screen’).cameraObject
To access the cameraObject attribute.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a9aaff00-9b03-4d3d-9e59-87c826a85e6co%40googlegroups.com.