Advertisement
lol_nl_py

Python tkinter password app

Sep 9th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import tkinter
  2. #username and password are admin
  3.  
  4. root = tkinter.Tk()
  5. root.title("Login")
  6. root.geometry("200x200")
  7.  
  8. def wrong():
  9.     msg = "Username or password is incorrect"
  10.     lbl_display["text"]=msg
  11.  
  12.  
  13.  
  14. def login():
  15.     user = txt_input_user.get()
  16.     password = txt_input_pass.get()
  17.     correct = "Welcome"
  18.     if user =="admin":
  19.         if password =="admin":
  20.             lbl_display["text"]=correct
  21.         else:
  22.             wrong()
  23.     else:
  24.         wrong()
  25.     txt_input_user.delete(0, "end")
  26.     txt_input_pass.delete(0, "end")
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. lbl_display_user = tkinter.Label(root, text="Username")
  37. lbl_display_user.pack()
  38.  
  39. txt_input_user = tkinter.Entry(root, width=15)
  40. txt_input_user.pack()
  41.  
  42. lbl_display_pass = tkinter.Label(root, text="Password")
  43. lbl_display_pass.pack()
  44.  
  45. txt_input_pass = tkinter.Entry(root, width=15)
  46. txt_input_pass.pack()
  47.  
  48. btn_login = tkinter.Button(root, text="Login", fg="green", command=login)
  49. btn_login.pack()
  50.  
  51. lbl_display = tkinter.Label(root, text="", fg="red")
  52. lbl_display.pack()
  53.  
  54. btn_exit = tkinter.Button(root, text="Exit", fg="red", command=exit)
  55. btn_exit.pack()
  56.    
  57.    
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement