Nabil-Ahmed

Login page

Dec 3rd, 2020
769
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import*
  2. from PIL import ImageTk
  3. import pymysql
  4. from tkinter import messagebox
  5.  
  6.  
  7. class The_Emargency_Lane:
  8.     def __init__(self, root):
  9.         self.root = root
  10.         self.root.title("The Emergency Lane")
  11.         self.root.geometry("1350x700+0+0")
  12.  
  13.         # ==========Image============
  14.  
  15.         self.bg_icon = ImageTk.PhotoImage(file="image/bg1.jpg")
  16.         self.user_icon = PhotoImage(file="image/user.png")
  17.         self.pass_icon = PhotoImage(file="image/padlock.png")
  18.         self.logo_icon = PhotoImage(file="image/ambulance.png")
  19.  
  20.         bg_lbl = Label(self.root, image=self.bg_icon).pack()
  21.  
  22.         title = Label(self.root, text="The Emargency Lane",
  23.                       font=("times new roman", 40, "bold"), bg="silver", fg="white", bd=10, relief=GROOVE)
  24.         title.place(x=0, y=0, relwidth=1)
  25.  
  26.         Login_Frame = Frame(self.root, bg="white")
  27.         Login_Frame.place(x=400, y=150)
  28.         logolbl = Label(Login_Frame,
  29.                         image=self.logo_icon, bd=0).grid(row=0, columnspan=2, pady=20)
  30.         lbluser = Label(Login_Frame, text="Username",
  31.                         image=self.user_icon, compound=LEFT, font=("times new roman", 20, "bold"), bg="white").grid(row=1, column=0, padx=20, pady=10)
  32.         self.txtuser = Entry(Login_Frame, bd=5, relief=GROOVE,
  33.                              font=("", 15)).grid(row=1, column=1, padx=20)
  34.  
  35.  
  36.         lblpass = Label(Login_Frame, text="Password",
  37.                         image=self.pass_icon, compound=LEFT, font=("times new roman", 20, "bold"), bg="white").grid(row=2, column=0, padx=20, pady=10)
  38.         self.txtpass = Entry(Login_Frame, bd=5, relief=GROOVE,
  39.                              font=("", 15)).grid(row=2, column=1, padx=20)
  40.  
  41.         btn_log = Button(Login_Frame, text="Login", command=self.login, width=15,
  42.                          font=("times new roman", 14, "bold"), bg="black", fg="white").grid(row=3, column=1, pady=10)
  43.  
  44.     def login(self):
  45.         if self.txtuser.get() == "" or self.txtpass.get() == "":
  46.             messagebox.showerror(
  47.                 "Error", "All fields are required", parent=self.root)
  48.         #print(self.txtuser(), self.txtpass())
  49.  
  50.  
  51. root = Tk()
  52. obj = The_Emargency_Lane(root)
  53. root.mainloop()
  54.  
RAW Paste Data