Advertisement
ALENTL

main.py

Oct 29th, 2022
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.80 KB | None | 0 0
  1. import mysql.connector as mc
  2. from tkinter import *
  3.  
  4. # MySQL Objects and connection string
  5. cnx = mc.connect(host="localhost", user="alen", password="alen", database="school")
  6. cur = cnx.cursor()
  7. cnx.autocommit = True
  8.  
  9. """
  10. Home function is the default home page. It consists of the  login page. It asks the user which group he/she belongs to ie (student, teacher, staff, admin)
  11. """
  12. def home():
  13.     window = Tk()
  14.     window.title("SCHOOL MANAGEMENT SYSTEM")
  15.     window.geometry("960x606")
  16.     window.resizable(0,0)
  17.     window.iconbitmap("./ico/school.ico")
  18.  
  19.     # Creating background image variable
  20.     bg = PhotoImage(file="./img/login.png")
  21.  
  22.     # Creating the background label
  23.     l1 = Label(window, image=bg)
  24.     l1.place(x=0, y=0)
  25.  
  26.     # Creating the login text
  27.     l2 = Label(window, text="LOGIN", font=("times new roman", 20, "bold"), bg="#184800", fg="#ff007f")
  28.     l2.place(x=441, y=23)
  29.  
  30.     # Creating the student button
  31.     l3 = Button(window, text="STUDENT", width=15, font=("times new roman",10, "bold"), command=lambda: stud_lgn_btn(window))
  32.     l3.place(x=435, y=100)
  33.  
  34.     # Creating the teacher button
  35.     l4 = Button(window, text="TEACHER", width=15, font=("times new roman", 10, "bold"))
  36.     l4.place(x=435, y=140)
  37.  
  38.     # Creating the staff button
  39.     l5 = Button(window, text="STAFF", width=15, font=("times new roman", 10, "bold"))
  40.     l5.place(x=435, y=180)
  41.  
  42.     # Creating the admin button
  43.     l6 = Button(window, text="ADMIN", width=15, font=("times new roman",10, "bold"))
  44.     l6.place(x=435, y=220)
  45.  
  46.     window.mainloop()
  47.  
  48. def stud_lgn_btn(window):
  49.     # Killing the previous window and moving to the student window
  50.     window.destroy()
  51.  
  52.     # Creating new window
  53.     root = Tk()
  54.  
  55.     root.title("STUDENT LOGIN")
  56.     root.geometry("960x600")
  57.     root.resizable(0,0)
  58.     root.iconbitmap("./ico/student.ico")
  59.    
  60.     # Creating the background image variable
  61.     bg = PhotoImage(file="./img/student_lgn.png")
  62.  
  63.     # Creating the label background
  64.     l1 = Label(root, image=bg)
  65.     l1.place(x=0, y=0)
  66.  
  67.     # Creating student login text
  68.     l2 = Label(root, text="STUDENT LOGIN", background="#413E91", font=("times new roman", 20, "bold"), fg="black")
  69.     l2.place(x=385, y=13)
  70.  
  71.     # Creating the login username text
  72.     lgnt1 = Label(root, text="USERNAME", font=("times new roman", 10, "bold"))
  73.     lgnt1.place(x=40, y=140)
  74.    
  75.     # Creating the username login entry form
  76.     user = Entry(root, width=20)
  77.     user.place(x=140, y=140)
  78.  
  79.     # Creating the login password text
  80.     lgnt2 = Label(root, text="PASSWORD", font=("times new roman", 10, "bold"))
  81.     lgnt2.place(x=40, y=180)
  82.  
  83.     # Creating the password entry form
  84.     pswd = Entry(root, width=20, show="*")
  85.     pswd.place(x=140, y=180)
  86.  
  87.     root.mainloop()
  88.  
  89. if __name__ == "__main__":
  90.     home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement