guneshs

login python

Oct 16th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.65 KB | None | 0 0
  1. import tkinter
  2. from tkinter import *
  3. from window2 import menu
  4. import db.db
  5. from tkinter import messagebox, Button
  6. from PIL import ImageTk, Image
  7.  
  8. #root=login page
  9. root1=menu
  10. #rootp=patient form
  11.  
  12. #variables
  13. root=None
  14. userbox=None
  15. passbox=None
  16. topframe=None
  17. bottomframe=None
  18. frame3=None
  19. login=None
  20.  
  21.  
  22. #command for login button
  23. def GET():
  24.     global userbox,passbox,error
  25.     S1 = userbox.get()
  26.     S2 = passbox.get()
  27.     data = (
  28.         S1,S2
  29.     )
  30.     if S1 == "":
  31.         messagebox.showinfo("Alert!", "Enter USERNAME First")
  32.     elif S2 == "":
  33.         messagebox.showinfo("Alert!", "Enter Password first")
  34.     else:
  35.         res = db.db.user_login(data)
  36.         if res:
  37.             # messagebox.showinfo("Message", "Login Successfully")
  38.             root.destroy()
  39.             menu()
  40.  
  41.         else:
  42.             messagebox.showinfo("Alert!", "Wrong username/password")
  43.  
  44.  
  45. #LOGIN PAGE WINDOW
  46. def Entry():
  47.     global userbox,passbox,login,topframe,bottomframe,image_1,root
  48.     root = tkinter.Tk()
  49.     # root.geometry("1000x600")
  50.     root.geometry("1920x1080")
  51.     root.iconbitmap('/Users/guneshs/PycharmProjects/HMSnhce/images/hms.ico')
  52.     basewidth = 1080
  53.     baseheight = 1920
  54.  
  55.     img = Image.open("/Users/guneshs/PycharmProjects/HMSnhce/images/hospital.jpeg")
  56.  
  57.     # wpercent = (basewidth / float(img.size[0]))
  58.     # hsize = int((float(img.size[1]) * float(wpercent)))
  59.     # hsize = int(hsize * 1.65)
  60.     # basewidth = img.size[1]
  61.     baseheight = int(baseheight * 0.89)
  62.     basewidth = int(basewidth * 0.9258)
  63.     img = img.resize((baseheight, basewidth ), Image.ANTIALIAS)
  64.  
  65.     background_image = ImageTk.PhotoImage(img)
  66.  
  67.     l = Label(root, image=background_image)
  68.     l.place(x=0, y=0)
  69.  
  70.     # topframe = tkinter.Frame(root)
  71.     # topframe.pack()
  72.     # bottomframe=tkinter.Frame(root)
  73.     # bottomframe.pack()
  74.  
  75.     # l = Label(image=img)
  76.     # l.pack()
  77.  
  78.     # heading = tkinter.Label(root, text="WELCOME TO Hospital Management System",font='Times 28 bold italic')
  79.  
  80.     # heading.place(relx=0.0, rely=1.0, anchor='sw')
  81.  
  82.     username=tkinter.Label(root, text="USERNAME", bg="green")
  83.     username.place(x=100, y=50 )
  84.     userbox = tkinter.Entry(root)
  85.     userbox.place(x=100, y=80)
  86.  
  87.     password=tkinter.Label(root, text="PASSWORD")
  88.     passbox = tkinter.Entry(root, show="*")
  89.  
  90.     login = tkinter.Button(root, text="LOGIN", bg="green", command=GET,font="arial 8 bold")
  91.  
  92.     # heading.pack()
  93.     username.pack()
  94.     userbox.pack()
  95.     password.pack()
  96.     passbox.pack()
  97.     login.pack()
  98.     # login.pack(side=tkinter.LEFT)
  99.     root.title("HOSPITAL MANAGEMENT SYSTEM")
  100.  
  101.  
  102.     root.mainloop()
  103.  
  104.  
  105.  
  106. Entry()
Add Comment
Please, Sign In to add comment