article

Saturday, August 27, 2022

Python Tkinter Simple Login form

Python Tkinter Simple Login form

#login.py
from tkinter import *
from tkinter import messagebox
 
def login():
    uname = e1.get()
    password = e2.get()
 
    if(uname == "" and password == "") :
        messagebox.showinfo("", "Blank Not allowed")
 
 
    elif(uname == "cairocoders" and password == "123456"):
 
        messagebox.showinfo("","Login Success")
        root.destroy()
 
    else :
        messagebox.showinfo("","Incorrent Username and Password")

root = Tk()
root.title("Login")
root.geometry("400x200")
global e1
global e2

Label(root, text="Login form using Python Tkinter").place(x=5, y=10)

Label(root, text="UserName").place(x=10, y=40)
Label(root, text="Password").place(x=10, y=60)

e1 = Entry(root)
e1.place(x=140, y=40)
 
e2 = Entry(root)
e2.place(x=140, y=60)
e2.config(show="*")
 
Button(root, text="Login", command=login ,height = 2, width = 13).place(x=10, y=100)

root.mainloop()

Related Post