2

I am currently trying to make a loading screen for Kivy application by switching screens.

#: import FadeTransition kivy.uix.screenmanager.FadeTransition


MyScreenManager:
    id: myscreenmanager
    transition: FadeTransition()
    PreLoadScreen:
    LoadingScreen:
    LoginScreen:

<PreLoadScreen>: 
    ...
<LoadingScreen>: 
    ...
<LoginScreen>: 
    ...

I am aware of how to change the screen by pushing a button like this.

    Button:
        text: 'Log In'
        on_release: 
        app.root.current = 'somescreen'

But I could not figure out how to automatically change the screen like,

(blank screen)

~automatically fades to

-> (screen with loading animation or image)

~when some loadings are done, fades to

-> (login screen)

Is there a good way I can do this without making any action such as on_release or on_touch_down?

BerryMan
  • 145
  • 1
  • 15

1 Answers1

0

Create the following python classes for each Kivy screen:

class PreLoadScreen(Screen):
   def switchToNextScreen(self) 
      self.parent.current = 'LoadingScreen'

class LoadingScreen(Screen):
    def switchToNextScreen(self):
        self.parent.current = 'PreLoadScreen'

class PreLoadScreen(Screen):
    def switchToNextScreen(self):
        self.parent.current = 'PreLoadScreen'

And then depending on your screen switch conditions, call switchToNextScreen, when you want to switch the current screen being displayed.

self.parent is the equivalent to app.root in your case. As you nest further into a class you will have to call parent repeatedly (self.parent.parent)

I hope this helps.

Tyler N
  • 44
  • 5