Advertisement
RealPikachu

If anyone has any updates please do so :)

Nov 16th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.05 KB | None | 0 0
  1. from tkinter import *
  2. import os
  3.  
  4. creds = 'tempfile.temp'  
  5. def Signup():
  6.     global pwordE
  7.     global nameE
  8.     global roots
  9.  
  10.     roots = Tk()
  11.     roots.title('Signup')
  12.     intruction = Label(roots, text='Please Enter new Credidentials\n')
  13.     intruction.grid(row=0, column=0, sticky=E)
  14.     r = Tk()
  15.     r.title('Username Requirements')
  16.     r.geometry('650x40')
  17.     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')
  18.     rlbl.pack()
  19.     r = Tk()
  20.     r.title('Password Requirements')
  21.     r.geometry('540x40')
  22.     rlbl = Label(r, text='For the password use one uppercase. Two numbers and symbols. Thank you. Example:$am!elrf4')
  23.     rlbl.pack()
  24.  
  25.     nameL = Label(roots, text='New Username: ')
  26.     pwordL = Label(roots, text='New Password: ')
  27.     nameL.grid(row=1, column=0, sticky=W)
  28.     pwordL.grid(row=2, column=0, sticky=W)
  29.  
  30.     nameE = Entry(roots)
  31.     pwordE = Entry(roots, show='*')
  32.     nameE.grid(row=1, column=1)
  33.     pwordE.grid(row=2, column=1)
  34.  
  35.     signupButton = Button(roots, text='Signup', command=FSSignup)
  36.     signupButton.grid(columnspan=2, sticky=W)
  37.     roots.mainloop()
  38.  
  39. def FSSignup():
  40.     with open(creds, 'w') as f:
  41.         f.write(nameE.get())
  42.         f.write('\n')
  43.         f.write(pwordE.get())
  44.         f.close()
  45.  
  46.     roots.destroy()
  47.     Login()
  48.    
  49.  
  50. def Login():
  51.     global nameEL
  52.     global pwordEL
  53.     global rootA
  54.  
  55.     rootA = Tk()
  56.     rootA.title('Login')
  57.  
  58.     intruction = Label(rootA, text='Please Login\n')
  59.     intruction.grid(sticky=E)
  60.  
  61.     nameL = Label(rootA, text='Username: ')
  62.     pwordL = Label(rootA, text='Password: ')
  63.     nameL.grid(row=1, sticky=W)
  64.     pwordL.grid(row=2, sticky=W)
  65.  
  66.     nameEL = Entry(rootA)
  67.     pwordEL = Entry(rootA, show='*')
  68.     nameEL.grid(row=1, column=1)
  69.     pwordEL.grid(row=2, column=1)
  70.  
  71.     loginB = Button(rootA, text='Login', command=CheckLogin)
  72.     loginB.grid(columnspan=2, sticky=W)
  73.  
  74.     rmuser = Button(rootA, text='Delete User', fg='red', command=DelUser)
  75.     rmuser.grid(columnspan=2, sticky=W)
  76.     rootA.mainloop()
  77.  
  78. def Quiz():
  79.     global nameEL
  80.     global pwordEL
  81.     global rootA
  82.     r = Tk()
  83.     r.title("Quiz")
  84.     rlbl = Label(r,text='\n[+] Welcome user!')
  85.     r.geometry('150x45')
  86.     rlbl.pack()
  87.     r = Tk()
  88.     r.title("Quiz")
  89.     rlbl = Label(r,text="This is a quiz about History and computing! Which one would you like to do first?")
  90.     r.geometry('500x35')
  91.     rlbl.pack()
  92.     master = Tk()
  93.     var1 = IntVar()
  94.     HistoryL = Checkbutton(master, text="History", variable=var1).grid(row=0, sticky=W)
  95.     var2 = IntVar()
  96.     ComputingL = Checkbutton(master, text="Computing", variable=var2).grid(row=1, sticky=W)
  97.     var1 = Button (rootA, text='History', fg='black', command=History)
  98.     var1.grid(columnspan=2, sticky=W)
  99.     var2 = Button (rootA, text='Computing', fg='black', command=Computing)
  100.     var2.grid(columnspan=2, sticky=W)
  101.     rootA.mainloop()
  102.  
  103. def History():
  104.     global nameEL
  105.     global pwordEL
  106.     global rootA
  107.     a = Tk()
  108.     a.title("History")
  109.  
  110. def Computing():
  111.     global nameEL
  112.     global pwordEL
  113.     global rootA
  114.     b = Tk()
  115.     b.title("Computing")
  116.  
  117. def CheckLogin():
  118.     with open(creds) as f:
  119.         data = f.readlines()
  120.         uname = data[0].rstrip()
  121.         pword = data[1].rstrip()
  122.  
  123.     if nameEL.get() == uname and pwordEL.get() == pword:
  124.         r = Tk()
  125.         r.title('Valid Details')
  126.         r.geometry('150x50')
  127.         rlbl = Label(r, text='\n[✔] Logged In')
  128.         rlbl.pack()
  129.         rmuser = Button(rootA, text='Next', fg='Blue', command=Quiz)
  130.         rmuser.grid(columnspan=2, sticky=W)
  131.         rootA.mainloop()
  132.     else:
  133.         r = Tk()
  134.         r.title('Invalid Details')
  135.         r.geometry('150x50')
  136.         rlbl = Label(r, text='\n[❌] Invalid Login')
  137.         rlbl.pack()
  138.         r.mainloop()
  139.  
  140. def DelUser():
  141.     os.remove(creds)
  142.     rootA.destroy()
  143.     Signup()
  144.  
  145. if os.path.isfile(creds):
  146.     Login()
  147. else:
  148.     Signup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement