I am building a password manager app using kivymd.I created a login screen window with two input fields and three buttons to login, register a nd clear text.I also created a database so that user login credentials can be verified. All is working fine and for now I assigned my login button a command to check for login credentials in database and if correct then show text on a lable as "Successfully loggined".
Now what I want is to create a new window /screen so that I can display the users their data(urls,usernames,passwords) and i want that if user clicks login button then after verifying all credentials in database, program should switch to new screen.
Can any one help?
BTW I CREATED A SEPERATE KV FILE FOR THIS PROJECT
from kivymd.app import MDApp
import sqlite3
class MainApp(MDApp):
def build(self):
return Builder.load_file("login.kv")
def login(self):
conn = sqlite3.connect("master.db")
cur = conn.cursor()
user = self.root.ids.user.text
password = self.root.ids.password.text
if user=="" or password=="" :
self.root.ids.error.markup=True
self.root.ids.error.text = "[b][color=#f50539]materuser & masterpassword required ![/b][/color]"
else:
cur.execute("SELECT rowid , *FROM master_database WHERE master_users = ?", (user,))
c=cur.fetchone()
conn.commit()
conn.close()
if c==None:
self.root.ids.error.markup=True
self.root.ids.error.text = f"No data for [color=#f50539][b]{user}[/b][/color]\nKindly register for [color=#f50539][b]new user ![/b][/color]"
else:
if c[2] == password:
self.root.ids.error.markup=True
self.root.ids.error.text = "[b]Successfully Loginned[b]"
else:
self.root.ids.error.markup=True
self.root.ids.error.text = "[b]Incorrect Password ![b]"
MainApp.run()
#KV file----->
MDCard:
size_hint:None,None
size:400,500
pos_hint:{"center_x":.5,"center_y":.5}
elevation:10
padding:25
spacing:25
orientation:"vertical"
MDRoundFlatButton:
id : log_in
text:"LOG IN"
font_size:12
pos_hint:{"center_x":.5}
on_release:app.login()
Please Provide the full code > BTW you can add screens on kivy file using
ScreenManager:
Main:
WelcomeScreen:
here main contains the login screen and when the user clicks the login button on it , the values are checked by your login() function and when all the things are correct switch to the second screen self.kv.get_screen('welcomescreen').manager.current = "welcomescreen"