Guest User

splash screen python file

a guest
Sep 8th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. from kivy.uix.screenmanager import Screen, ScreenManager, NoTransition
  2. from kivymd.app import MDApp
  3. from kivy.clock import Clock
  4. import os
  5.  
  6. BASE_PATH = os.path.abspath('./utils/design_files/')
  7.  
  8. class SplashScreen(Screen):
  9.     def __init__(self, **kw):
  10.         self._splash_kv_file = Builder.load_file(filename=f"{BASE_PATH}/splash_screen_design.kv")
  11.         super().__init__(**kw)
  12.         self.tip_labels = ["Tip 1: Your tip text here.",
  13.                            "Tip 2: Another tip text.",
  14.                            "Tip 3: More tips...",
  15.                            "Tip 4: Customize your tips."]
  16.         self.show_random_tip()
  17.  
  18.     def show_random_tip(self):
  19.         self.ids.tip_label.text = choice(self.tip_labels)
  20.  
  21. class MyApp(MDApp):
  22.     def __init__(self, **kwargs):
  23.         super().__init__(**kwargs)
  24.         self.screen = None
  25.  
  26.     def build(self):
  27.         self.title = "My-App"
  28.  
  29.         # Create a ScreenManager with no transition
  30.         screen_manager = ScreenManager(transition=NoTransition())
  31.         splash_screen = SplashScreen(name='splash')
  32.         screen_manager.add_widget(splash_screen)
  33.         Clock.schedule_once(self.switch_to_main_screen, 5)
  34.         return screen_manager
  35.  
  36.     def switch_to_main_screen(self, _):
  37.         pass
  38.    
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment