Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody, I have designed a splash screen that will display the logo of the app and after 3 seconds it will be transferred to the login page. The splash and login screens are designed in two separate .kv files. The problem I have encountered is that I have a Repeating loop and screens are displayed synchronous after 3 sec.

What I have tried:

main.py file
Python
class SplashScreen(MDScreen):
    def on_enter(self, *args):
        Clock.schedule_once(self.switch_to_home, 3)
    def switch_to_home(self, dt):
        LoginApp().run()
class LoginApp(MDApp):
    def build(self):
        self.manager = ScreenManager()
        self.manager.add_widget(Login(name='login'))
        return self.manager
class StartPage(MDApp):
    def build(self):
        return Builder.load_file('logo.kv')
if __name__ == '__main__':
    StartPage().run()

logo.kv file
ScreenManager:
    orientation:'vertical'
    SplashScreen:
        name: 'Splash'
        Image:
            source:'logo.png'
            pos_hint:{'center_x':0.5,'center_y':.6}
        MDLabel:
            text: "LEITNER"
            halign:'center'
            pos_hint:{'center_x':0.5,'center_y':.3}

login.kv
<Login>:
    name:'login'
    Image:
        source:'logo.png'
        pos_hint:{'center_x':0.5,'center_y':.9}
    MDTextFieldRound:
        id: user
        hint_text: "username"
        icon_right: "account"
        size_hint_x: None
        width: 200
        font_size: 18
        pos_hint: {"center_x": 0.5,'center_y':.7}
    MDTextFieldRound:
        id: password
        hint_text: "password"
        icon_right: "eye-off"
        size_hint_x: None
        width: 200
        font_size: 18
        pos_hint: {"center_x": 0.5,'center_y':.6}
        password: True
    MDRoundFlatButton:
        text: "LOG IN"
        font_size: 12
        pos_hint: {"center_x": 0.5,'center_y':.4}
        on_press: root.connect()

login.py file
Python
from kivy.uix.screenmanager import Screen, SlideTransition
from kivymd.toast import toast
class Login(Screen):
    pass

    def connect(self):
        toast('Login and Password are correct!')
Posted
Updated 2-Aug-22 21:49pm
v2
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900