79081500

Date: 2024-10-12 17:08:36
Score: 0.5
Natty:
Report link

I found a solution for adding a splash screen. It suddenly occurred to me that having the popup code in my app's __init__() method could be the cause of the problem, because the app might not be finished initializing and therefore not ready to display a popup.

Moving the popup code to my app's build() method also did not work, probably for similar reasons.

So I coded the following:

    def __init__(self, **kwargs):
        super().__init__()
        self._popup = None

    def build(self):
        # show splash screen immediately after build() completes
        Clock.schedule_once(self.ShowSplashScreen, 0)
        return self.mainLayout

    def ShowSplashScreen(self, *args):
        content = LoadSplashScreenDialog(cancel=self.dismiss_popup)
        self._popup = Popup(title="Test App", content=content, size_hint=(1.0, 1.0))
        self._popup.open()
        Clock.schedule_once(self.dismiss_popup, 2)

By scheduling the popup to display in the next frame, it will display immediately after the build() method completes and the app is instantiated.

Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Todd Hoatson