Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- #username and password are admin
- root = tkinter.Tk()
- root.title("Login")
- root.geometry("200x200")
- def wrong():
- msg = "Username or password is incorrect"
- lbl_display["text"]=msg
- def login():
- user = txt_input_user.get()
- password = txt_input_pass.get()
- correct = "Welcome"
- if user =="admin":
- if password =="admin":
- lbl_display["text"]=correct
- else:
- wrong()
- else:
- wrong()
- txt_input_user.delete(0, "end")
- txt_input_pass.delete(0, "end")
- lbl_display_user = tkinter.Label(root, text="Username")
- lbl_display_user.pack()
- txt_input_user = tkinter.Entry(root, width=15)
- txt_input_user.pack()
- lbl_display_pass = tkinter.Label(root, text="Password")
- lbl_display_pass.pack()
- txt_input_pass = tkinter.Entry(root, width=15)
- txt_input_pass.pack()
- btn_login = tkinter.Button(root, text="Login", fg="green", command=login)
- btn_login.pack()
- lbl_display = tkinter.Label(root, text="", fg="red")
- lbl_display.pack()
- btn_exit = tkinter.Button(root, text="Exit", fg="red", command=exit)
- btn_exit.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement