Reputation: 141
I am trying to make an app with kivy and kivymd but I can't figure out how I can make the setup screen show up only the first time. This is how the application is going to work: User launches the application after installation and is being shown the sign up/log in screen, And once the user is done with the setup, the setup screens will never appear again unless the user reinstalls the application.
How can I make this happen? Please help and thanks SO much in advance!
Upvotes: 0
Views: 452
Reputation: 1
It is so easy just follow this: First import os module and then use a conditional statement
Note: Here I have two screens, 'start' and 'intro' , I want to show my 'intro' screen if it's the first time the user start the app, and for next times he/she won't face this screen ever. If user started this app before there will be 'database.db' file and app should start with 'start' screen, otherwise app should be started with 'intro' screen which for me contains an function.
Code will be something like the following:
from os.path import exists
def on_enter(self,*args):
if exists('database.db'):
self.ids.screenmanager.current = 'start'
else:
self.animIt()
my kvfile is like this:
<MyScreen>:
MDScreenManager:
id:screenmanager
MDScreen:
name:'intro'
MDScreen:
name:'start'
Depending on your app items change
Upvotes: 0
Reputation: 141
I fixed this problem by creating and reading a "text" file.My "text" file has '0' as a boolean
variable .Once the user is done with signing up / logging in , I change that "text" file to '1' ,and in the __init__
func, I check if that file equals to '0' or '1'.
I'm not sure if this is the correct way or not,but this worked for me.
Upvotes: 1