Create Password for Executing your GUI

 Just changer your username and password in code and run

import os
import time
from tkinter import *
from PIL import ImageTk,Image
def project():
#password on runing gui code
def main():
while True:

UserName = input ("Enter Username: ")
PassWord = input ("Enter Password: ")

if UserName == 'fahadalikhan' and PassWord == '0309':
time.sleep(1)
print ("Login successful!")
logged()


else:
print ("Password did not match!")

def logged():
time.sleep(1)
print ("Beardo_SuperCode()")

def project_1():
root = Tk()
app_width = 600
app_height = 600
scr_width = root.winfo_screenwidth()
scr_height = root.winfo_screenheight()
xcord = (scr_width / 2) - (app_width / 2)
ycord = (scr_height / 2) - (app_height / 2)
root.geometry("%dx%d+%d+%d" % (app_width, app_height, xcord, ycord))
root.configure(background="#979069")

def close_app():
root2.destroy()
bt["state"] = ["normal"]

def c_t(e):
if v_1.get() == "user id":
v_1.delete(0, END)

def c_t_2(e1):

if v_2.get() == "password":
v_2.delete(0, END)
v_2.config(show="*")

def n_w():
global v_1, v_2
global root2
bt['state'] = ['disable']
root2 = Toplevel(root)
root2.protocol("WM_DELETE_WINDOW", close_app)
app_width = 600
app_height = 400
scr_width = root2.winfo_screenwidth()
scr_height = root2.winfo_screenheight()
xcord = (scr_width / 2) - (app_width / 2)
ycord = (scr_height / 2) - (app_height / 2)
root2.geometry("%dx%d+%d+%d" % (app_width, app_height, xcord, ycord))
root2.title("General Store")
root2.iconbitmap("E:\\python projects\\shops_awP_icon.ico")
back_image = Image.open("C:\\Users\\Fahad Ali Khan\\Desktop\\a.jpg")
set_image = ImageTk.PhotoImage(back_image)
l1 = Label(root2, image=set_image).place(x=0, y=0, relwidth=1, relheight=1)
welcome_note_2 = Label(root2, text="Login", bg="#1c1750", fg="#18705e", bd=6, width=100, relief=RAISED,
font="Helvetica 12 bold", justify=CENTER)
welcome_note_2.pack(fill="y")
u_n = StringVar()
u_n.set("user id")
pas = StringVar()
pas.set("password")
v_1 = Entry(root2, textvariable=u_n, bg="#1c1750", fg="#98bcc2", bd=6, width=20, relief=RAISED,
font="Helvetica 12 bold", justify=CENTER)
# v_1.bind("<Button-1>",c_t)
v_1.bind("<FocusIn>", c_t)
v_1.place(x=200, y=100)
v_2 = Entry(root2, textvariable=pas, bg="#1c1750", fg="#98bcc2", bd=6, width=20, relief=RAISED,
font="Helvetica 12 bold", justify=CENTER)
# v_2.bind("<Button-1>", c_t)
v_2.bind("<FocusIn>", c_t_2)
v_2.place(x=200, y=150)

# writing function to show or hide password
# important
def show_pass():

if v_2.cget("show") == "":
v_2.config(show='*')
pass_show.config(text='Show Password')
else:
v_2.config(show='')
pass_show.config(text='Hide Password')

pass_show = Button(root2, text="Show Password", command=show_pass, bg="#1c1750", fg="#98bcc2", bd=0,
relief=RAISED,
justify=CENTER)
# login button

l_btn = Button(root2, text="Login", bg="#1c1750", fg="#98bcc2", bd=6, width=20, relief=RAISED,
font="Helvetica 12 bold", justify=CENTER)
l_btn.pack(pady=170)
pass_show.place(x=395, y=155)
root2.maxsize(600, 400)
root2.minsize(600, 400)
root2.mainloop()

root.title("Shop Manager")
root.iconbitmap("E:\\python projects\\shops_awP_icon.ico")
welcome_note = Label(root, text="Welcome To The Shop Manager", bg="#a2812a", bd=6, width=100, relief=RAISED,
font="Helvetica 12 bold", justify=CENTER).pack()
bt = Button(root, text="Log In", command=n_w, bg="#a2812a", bd=6, width=10, relief=RIDGE,
font="Helvetica 12 bold",
justify=CENTER)
bt.pack(pady=3)
bt2 = Button(root, text="Exit", command=root.destroy, bg="#a2812a", bd=6, width=10, relief=RIDGE,
font="Helvetica 12 bold", justify=CENTER)
bt2.pack(side=BOTTOM, pady=3)


root.mainloop()

project_1()
main()
project()



























Comments