Here some code of my project. I access email from database but password didn't access. help me... from tkinter import *
class karate(Tk): def init(self, *args, **kwargs): Tk.init(self, *args, **kwargs) self.state("zoomed") self.protocol("WM_DELETE_WINDOW",self.on_exit) # when click X button for close app then ask yes or no #create icon for app self.iconbitmap(r"C:\Users\RAHUL SHARMA\Desktop\Python Program\GUI\logo.ico") # the container is where we'll stack a bunch of frames # on top of each other, then the one we want visible # will be raised above the others container = Frame(self) container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1)
#self.menubar=MenuBar(self)
#self.config(menu=self.menubar)
#self.meenubar()
self.frames = {}
for F in (LoginPage,ForgetPassPage,SignUpPage,StartPage,PageOne,PageTwo,TotalKaratekas,ByAge,ByMedal,ByCoach,NewData):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
# put all of the pages in the same location;
# the one on the top of the stacking order
# will be the one that is visible.
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("LoginPage","Shito Ryu Karate Do India: Devloper: RAHUL SHARMA")
def show_frame(self, page_name,title):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise()
self.title(title)#WINDOW BAR TITLE
def get_page(self, page_class):
return self.frames[page_class]
def on_exit(self):
if messagebox.askyesno("Confirm Exit", "Thanks for use SKDI app.\nDo you want to quit the application?"):
self.destroy()
def meenubar(self):
self.menubar = MenuBar(self)
self.config(menu=self.menubar)
def MenuBarHide(self):
self.menubar.delete(0, END)
class LoginPage(Frame): def init(self, parent, controller): Frame.init(self, parent) self.controller = controller
# Frames
self.TopFrame = Frame(self, bd=5, relief=RIDGE)
self.TopFrame.place(x=500, y=330)
self.ButtonFrame = Frame(self, bd=5, relief=RIDGE)
self.ButtonFrame.place(x=500,y=420)
# labels
self.UserLoginLabel = Label(self, text="USER LOGIN", font=("Bold"), fg="Red")
#self.UserLoginLabel.place(x=190,y=173)
self.usernameLabel = Label(self.TopFrame, text="Email:", font=("Bold"))
self.usernameLabel.grid(row=1, column=0, padx=15, pady=15)
self.PasswordLabel = Label(self.TopFrame, text="Password:", font=("Bold"))
self.PasswordLabel.grid(row=2, column=0)
#variables
self.EmailVar = StringVar()
self.password_var = StringVar()
self.PassSetVar = StringVar()
# Entrys
self.usernameEntry = Entry(self.TopFrame, textvariable=self.EmailVar, bd=4, font=("Bold"), width=15,justify=CENTER)
self.usernameEntry.grid(row=1, column=1, padx=20, ipadx=20)
self.usernameEntry.focus()
self.usernameEntry.insert(0,"example@gmail.com")
self.usernameEntry.bind("<Return>",self.Login)
self.PasswordEntry = Entry(self.TopFrame, textvariable=self.password_var, bd=4, font=("Bold"), width=15,show="*", justify=CENTER)
self.PasswordEntry.grid(row=2, column=1, padx=20, ipadx=20)
self.PasswordEntry.bind("<Return>",self.Login)
self.PasswordSetEntry = Entry(self, textvariable=self.PassSetVar, bd=4, font=("Bold"), width=15, justify=CENTER)
self.PasswordSetEntry.place(x=20,y=20)
# Buttons
self.SignUpButton = Button(self.ButtonFrame, text="SignUp",command=lambda :self.controller.show_frame("SignUpPage","Signup page"), font=("Bold"), relief=FLAT, cursor="hand2")
self.SignUpButton.grid(row=0, column=0)
self.LoginButton = Button(self.ButtonFrame, text="Login", command=lambda: self.Login(self), font=("Bold"),relief=FLAT,cursor="hand2")
self.LoginButton.grid(row=0, column=1,padx=25)
self.LoginButton.bind('<Return>', self.Login)
self.ForgetButton = Button(self.ButtonFrame, text="Forget Password",command=lambda :self.controller.show_frame("ForgetPassPage","Forget password")
,font=("Bold"),cursor="hand2",relief=FLAT)
self.ForgetButton.grid(row=0, column=2)
def LoginName_Var(self):
startpage = self.controller.get_page("StartPage")
cur = con.cursor()
cur.execute("SELECT Name FROM login WHERE Email = ? AND password = ? ",
(self.EmailVar.get(), self.password_var.get()))
record = cur.fetchall()
tk = len(record)
for row in record:
startpage.LoginNameVar.set(record[0])
def Login(self, event):
if (self.EmailVar.get() != "" and self.password_var.get() != ""):
cur = con.cursor()
cur.execute('SELECT Email FROM login WHERE Email = ? ', (self.EmailVar.get(),))
record = cur.fetchall()
tk = len(record)
if tk == 0:
msg = messagebox.showerror("Registration form", "Email does not exist")
self.usernameEntry.config(highlightthickness=1, highlightcolor="Red")
self.usernameEntry.focus()
else:
cur = con.cursor()
cur.execute('SELECT password FROM login WHERE Email = ? ', (self.EmailVar.get(),))
self.PassRecord = cur.fetchall()
ps = self.PassSetVar.set(self.PassRecord)
if(PS == self.password_var.get()):
try:
self.controller.show_frame("StartPage", "StartPage: Developer Rahul Sharma")
self.controller.meenubar()
self.LoginName_Var()
self.password_var.set("")
self.usernameEntry.config(highlightthickness=0)
self.PasswordEntry.config(highlightthickness=0)
except Exception as e:
print(e)
else:
print(self.PassRecord)
print(self.password_var.get())
msg = messagebox.showerror("Registration form", "Entered wrong password")
self.usernameEntry.config(highlightthickness=0)
self.PasswordEntry.config(highlightthickness=1, highlightcolor="Red")
self.PasswordEntry.focus()
else:
msg = messagebox.showinfo("Login", "Please fill username and Password")