Guest User

Untitled

a guest
Dec 4th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox as tm
  3.  
  4.  
  5. class LoginFrame(Frame):
  6. def __init__(self, master):
  7. super().__init__(master)
  8.  
  9. self.label_username = Label(self, text="Username")
  10. self.label_password = Label(self, text="Password")
  11.  
  12. self.entry_username = Entry(self)
  13. self.entry_password = Entry(self, show="*")
  14.  
  15. self.label_username.grid(row=0, sticky=E)
  16. self.label_password.grid(row=1, sticky=E)
  17. self.entry_username.grid(row=0, column=1)
  18. self.entry_password.grid(row=1, column=1)
  19.  
  20. self.checkbox = Checkbutton(self, text="Keep me logged in")
  21. self.checkbox.grid(columnspan=2)
  22.  
  23. self.logbtn = Button(self, text="Login", command=self._login_btn_clicked)
  24. self.logbtn.grid(columnspan=2)
  25.  
  26. self.pack()
  27.  
  28. def _login_btn_clicked(self):
  29. # print("Clicked")
  30. username = self.entry_username.get()
  31. password = self.entry_password.get()
  32.  
  33. # print(username, password)
  34.  
  35. if username == "Rio" and password == "Computing123":
  36. tm.showinfo("Login info", "Welcome Admin")
  37.  
  38.  
  39. elif username == "Halford" and password == "password":
  40. tm.showinfo("Login info", "Welcome Sir")
  41.  
  42.  
  43.  
  44.  
  45. print("Welcome to the quiz you now have full access for this quiz")
  46. start = input("Would you like to play the quiz")
  47. if start = "Yes"
  48.  
  49. else:
  50. tm.showerror("Login error", "Incorrect username")
  51.  
  52.  
  53.  
  54. root = Tk()
  55. lf = LoginFrame(root)
  56. root.mainloop()
Add Comment
Please, Sign In to add comment