|
| 1 | +from tkinter import * |
| 2 | + |
| 3 | +window = Tk() |
| 4 | +window.title("ItsExceptional") |
| 5 | +window.geometry("300x200") |
| 6 | +window.config(background = "black", pady=10) |
| 7 | + |
| 8 | +lb1 = Label(window, text = "Login Form", bg = "black", fg="white", font=20) |
| 9 | +lb1.place(x=110, y=5) |
| 10 | + |
| 11 | +lb2_u = Label(window, text = "Username - ", bg="black", fg="white") |
| 12 | +lb2_u2 = Entry(window) |
| 13 | +lb2_u.place(x=10, y=40) |
| 14 | +lb2_u2.place(x=110, y=40) |
| 15 | + |
| 16 | +lb2_p = Label(window, text = "Password - ", bg="black", fg="white") |
| 17 | +lb2_p2 = Entry(window) |
| 18 | +lb2_p.place(x=10, y=80) |
| 19 | +lb2_p2.place(x=110,y=80) |
| 20 | + |
| 21 | + |
| 22 | +display = Label(window, text="Access : ", bg="black") |
| 23 | + |
| 24 | +bt = Button(window, text="Login") |
| 25 | + |
| 26 | +def dis(): |
| 27 | + user = lb2_u2.get() |
| 28 | + pas = lb2_p2.get() |
| 29 | + filo = open('register.txt').readlines() |
| 30 | + for lino in filo: |
| 31 | + if user == lino.split()[2]: |
| 32 | + display.config(bg="green",fg="white", text="Access :Granted") |
| 33 | + break |
| 34 | + else: |
| 35 | + display.config(bg="red",fg="white", text="Access :Denied") |
| 36 | + |
| 37 | +bt.config(command=dis) |
| 38 | +bt.place(x=110, y=120) |
| 39 | + |
| 40 | +def newsign(): |
| 41 | + sign=Tk() |
| 42 | + sign.title("SignUp") |
| 43 | + sign.geometry("300x200") |
| 44 | + sign.config(background = "black", pady=10) |
| 45 | + |
| 46 | + lbs = Label(sign, text = "SignUp", bg = "black", fg="white", font=20) |
| 47 | + lbs.place(x=110, y=5) |
| 48 | + |
| 49 | + lb2_s = Label(sign, text = "Username - ", bg="black", fg="white") |
| 50 | + lb2_s2 = Entry(sign) |
| 51 | + lb2_s.place(x=10, y=40) |
| 52 | + lb2_s2.place(x=110, y=40) |
| 53 | + |
| 54 | + lb2_ps = Label(sign, text = "Password - ", bg="black", fg="white") |
| 55 | + lb2_ps2 = Entry(sign) |
| 56 | + lb2_ps.place(x=10, y=80) |
| 57 | + lb2_ps2.place(x=110,y=80) |
| 58 | + |
| 59 | + dis = Label(sign, text ="", bg="black", fg="white") |
| 60 | + |
| 61 | + def reg(): |
| 62 | + username = lb2_s2.get() |
| 63 | + pas = lb2_ps2.get() |
| 64 | + |
| 65 | + file = open("register.txt","a") |
| 66 | + fiIn = open('register.txt').readlines() |
| 67 | + |
| 68 | + l=[] |
| 69 | + for lines in fiIn: |
| 70 | + l.append(lines.split()[1]) |
| 71 | + |
| 72 | + if username in l: |
| 73 | + print("Exists") |
| 74 | + dis.config(text="User Exists", bg="green") |
| 75 | + |
| 76 | + else: |
| 77 | + print("not Exists") |
| 78 | + file.write("Username = "+username+"\n") |
| 79 | + file.write("Password = "+pas+"\n") |
| 80 | + file.close() |
| 81 | + dis.config(text = "Registered", bg="green") |
| 82 | + |
| 83 | + bts = Button(sign, text="Register", command=reg) |
| 84 | + bts.place(x=110, y=120) |
| 85 | + dis.place(x=100, y=150) |
| 86 | + |
| 87 | + window.destroy() |
| 88 | + |
| 89 | +bt2 = Button(window, text="SignUp", command=newsign) |
| 90 | +bt2.place(x=170, y=120) |
| 91 | + |
| 92 | +display.place(x=110, y=155) |
0 commit comments