Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import os
- creds = 'tempfile.temp'
- def Signup():
- global pwordE
- global nameE
- global roots
- roots = Tk()
- roots.title('Signup')
- intruction = Label(roots, text='Please Enter new Credidentials\n')
- intruction.grid(row=0, column=0, sticky=E)
- r = Tk()
- r.title('Username Requirements')
- r.geometry('650x40')
- rlbl = Label(r, text='For the Username Please use the first three letters of your name and your age at the end. Example:Kamil...15...Kam15')
- rlbl.pack()
- r = Tk()
- r.title('Password Requirements')
- r.geometry('540x40')
- rlbl = Label(r, text='For the password use one uppercase. Two numbers and symbols. Thank you. Example:$am!elrf4')
- rlbl.pack()
- nameL = Label(roots, text='New Username: ')
- pwordL = Label(roots, text='New Password: ')
- nameL.grid(row=1, column=0, sticky=W)
- pwordL.grid(row=2, column=0, sticky=W)
- nameE = Entry(roots)
- pwordE = Entry(roots, show='*')
- nameE.grid(row=1, column=1)
- pwordE.grid(row=2, column=1)
- signupButton = Button(roots, text='Signup', command=FSSignup)
- signupButton.grid(columnspan=2, sticky=W)
- roots.mainloop()
- def FSSignup():
- with open(creds, 'w') as f:
- f.write(nameE.get())
- f.write('\n')
- f.write(pwordE.get())
- f.close()
- roots.destroy()
- Login()
- def Login():
- global nameEL
- global pwordEL
- global rootA
- rootA = Tk()
- rootA.title('Login')
- intruction = Label(rootA, text='Please Login\n')
- intruction.grid(sticky=E)
- nameL = Label(rootA, text='Username: ')
- pwordL = Label(rootA, text='Password: ')
- nameL.grid(row=1, sticky=W)
- pwordL.grid(row=2, sticky=W)
- nameEL = Entry(rootA)
- pwordEL = Entry(rootA, show='*')
- nameEL.grid(row=1, column=1)
- pwordEL.grid(row=2, column=1)
- loginB = Button(rootA, text='Login', command=CheckLogin)
- loginB.grid(columnspan=2, sticky=W)
- rmuser = Button(rootA, text='Delete User', fg='red', command=DelUser)
- rmuser.grid(columnspan=2, sticky=W)
- rootA.mainloop()
- def Quiz():
- global nameEL
- global pwordEL
- global rootA
- r = Tk()
- r.title("Quiz")
- rlbl = Label(r,text='\n[+] Welcome user!')
- r.geometry('150x45')
- rlbl.pack()
- r = Tk()
- r.title("Quiz")
- rlbl = Label(r,text="This is a quiz about History and computing! Which one would you like to do first?")
- r.geometry('500x35')
- rlbl.pack()
- master = Tk()
- var1 = IntVar()
- HistoryL = Checkbutton(master, text="History", variable=var1).grid(row=0, sticky=W)
- var2 = IntVar()
- ComputingL = Checkbutton(master, text="Computing", variable=var2).grid(row=1, sticky=W)
- var1 = Button (rootA, text='History', fg='black', command=History)
- var1.grid(columnspan=2, sticky=W)
- var2 = Button (rootA, text='Computing', fg='black', command=Computing)
- var2.grid(columnspan=2, sticky=W)
- rootA.mainloop()
- def History():
- global nameEL
- global pwordEL
- global rootA
- a = Tk()
- a.title("History")
- def Computing():
- global nameEL
- global pwordEL
- global rootA
- b = Tk()
- b.title("Computing")
- def CheckLogin():
- with open(creds) as f:
- data = f.readlines()
- uname = data[0].rstrip()
- pword = data[1].rstrip()
- if nameEL.get() == uname and pwordEL.get() == pword:
- r = Tk()
- r.title('Valid Details')
- r.geometry('150x50')
- rlbl = Label(r, text='\n[✔] Logged In')
- rlbl.pack()
- rmuser = Button(rootA, text='Next', fg='Blue', command=Quiz)
- rmuser.grid(columnspan=2, sticky=W)
- rootA.mainloop()
- else:
- r = Tk()
- r.title('Invalid Details')
- r.geometry('150x50')
- rlbl = Label(r, text='\n[❌] Invalid Login')
- rlbl.pack()
- r.mainloop()
- def DelUser():
- os.remove(creds)
- rootA.destroy()
- Signup()
- if os.path.isfile(creds):
- Login()
- else:
- Signup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement