I try to call a function on my Screenmanager after a button was pressed. But the call to (App.get_running_app().root.) does not get me an object.
There seems to be an issue that i do not have a root object, but why. It worked before i tried it with the dashboard.
I have tried including methods from the ScreenManager Class which i could not call and call methods out of the Dashboard class, which function.
python file:
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.app import App
class DashboardScreen(Screen):
def __init__(self, **kwargs):
super(DashboardScreen, self).__init__(**kwargs)
# Initialize Target Container
App.get_running_app().root.get_character_selection_screen()
class MyScreenManager(ScreenManager):
def __init__(self, **kwargs):
super(MyScreenManager, self).__init__(**kwargs)
self.add_widget(DashboardScreen(name='dashboard'))
def get_character_selection_screen(self):
pass
class MatrixApp(App):
def build(self):
return MyScreenManager()
if __name__ == '__main__':
MatrixApp().run()
Kivy File:
<DashboardScreen>:
BoxLayout:
orientation: "vertical"
Label:
text: "test"
Error Message AttributeError: 'NoneType' object has no attribute 'get_character_selection_screen'
Indentation might be messed up, because i tried to upload it here.
Try to schedule it with clock, so you are sure the app and widgets are ready
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.app import App
from kivy.clock import Clock
class DashboardScreen(Screen):
def __init__(self, **kwargs):
super(DashboardScreen, self).__init__(**kwargs)
Clock.schedule_once(self.after_init)
def after_init(self, dt):
App.get_running_app().root.get_character_selection_screen()