Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def stud_lgn_btn(window):
- # Killing the previous window and moving to the student window
- window.destroy()
- # Making the tkinter window global
- global root
- # Creating new window
- root = Tk()
- root.title("STUDENT LOGIN")
- root.geometry("960x600")
- root.resizable(0, 0)
- root.iconbitmap("./ico/student.ico")
- # Creating String Vars
- global username_var
- global passw_var
- username_var = StringVar()
- passw_var = StringVar()
- # Creating the background image variable
- bg = PhotoImage(file="./img/all_lgn.png")
- # Creating the label background
- l1 = Label(root, image=bg)
- l1.place(x=0, y=0)
- # Creating student login text
- l2 = Label(root, text="STUDENT LOGIN", background="#413E91",
- font=("times new roman", 20, "bold"), fg="black")
- l2.place(x=385, y=13)
- # Creating the login username text
- lgnt1 = Label(root, text="USERNAME", font=("times new roman", 10, "bold"))
- lgnt1.place(x=40, y=140)
- # Creating the username login entry form
- global user
- user = Entry(root, textvariable=username_var, width=20)
- user.place(x=140, y=140)
- # Creating the login password text
- lgnt2 = Label(root, text="PASSWORD", font=("times new roman", 10, "bold"))
- lgnt2.place(x=40, y=180)
- # Creating the password entry form
- pswd = Entry(root, textvariable=passw_var, width=20, show="*")
- pswd.place(x=140, y=180)
- # Creating the submit button
- submit = Button(root, text="SUBMIT", command=stud_lgn)
- submit.place(x=130, y=220)
- root.mainloop()
- """
- The stud_lgn() function is used to check for the username and password in the database and make further movements
- Tt uses the global username_var and password_var for checking the values
- It used .get() method to get the str() return of the entered value from the report
- Then that value is used to validate the student using mysql connection
- If the entered value is correct then this window proceeds into stud_home()
- If not then the window will show an error message stating 'Cannot find such a user with the given username and passweord. Please retry'
- """
- def stud_lgn():
- name = username_var.get()
- passw = passw_var.get()
- cur.execute(
- "SELECT * FROM STUDENTS WHERE USERNAME=%s AND PASSWORD=%s", (name, passw))
- a = cur.fetchone()
- global L
- L = []
- if a !=None and len(a) != 0:
- for k in a:
- L.append(k)
- root.destroy()
- stud_home()
- else:
- messagebox.showerror(
- "User nor found", "Cannot find such a user with the given username and password. Please retry")
- username_var.set("")
- passw_var.set("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement