Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #%%
  2. from tkinter import *
  3.  
  4. def adminLogin():
  5. global AnameEL
  6. global ApwordEL # More globals :D
  7. global ArootA
  8.  
  9. AnameL = Label(f2, text='Username: ') # More labels
  10. ApwordL = Label(f2, text='Password: ') # ^
  11. AnameL.grid(row=1, sticky=W)
  12. ApwordL.grid(row=2, sticky=W)
  13.  
  14. AnameEL = Entry(f2) # The entry input
  15. ApwordEL = Entry(f2, show='*')
  16. AnameEL.grid(row=1, column=1)
  17. ApwordEL.grid(row=2, column=1)
  18.  
  19. AloginB = Button(f2, text='Login', command=CheckAdmin) # This makes the login button, which will go to the CheckLogin def.
  20. AloginB.grid(columnspan=2, sticky=W)
  21.  
  22.  
  23. def CheckAdmin():
  24. if AnameEL.get() == "test" and ApwordEL.get() == "123" : # Checks to see if you entered the correct data.
  25. f2.destroy()
  26. #r = Tk() # Opens new window
  27. loginL = Label(f3, text = 'Success!!!')
  28. loginC = Button(f3, text='Add new login', command=Signup)
  29. loginL.grid(row = 2, column=0, sticky=W)
  30. loginC.grid(columnspan=2, sticky=E)
  31. #r.mainloop()
  32. else:
  33. f2.destroy()
  34. #r = Tk() # Opens new window
  35. loginL2 = Label(f3, text = 'Error!!')
  36. ribl = Label(f3, text='\n[!] Invalid Login')
  37. loginL2.grid(row = 2, column=0, sticky=W)
  38. ribl.grid(row = 3, column=0, sticky=W)
  39.  
  40. #.mainloop()
  41.  
  42.  
  43. def Signup(): # This is the signup definition,
  44. global pwordE # These globals just make the variables global to the entire script, meaning any definition can use them
  45. global nameE
  46. global roots
  47.  
  48. f3.destroy()
  49. #r = Tk() # Opens new window
  50. loginL3 = Label(f4, text = 'Signup!!!') # This renames the title of said window to 'signup'
  51. loginL3.grid(row = 0, column=50, sticky=W)
  52.  
  53. intruction = Label(f4, text='Please Enter new Credidentials\n') # This puts a label, so just a piece of text saying 'please enter blah'
  54. intruction.grid(row=2, column=0, sticky=E) # This just puts it in the window, on row 0, col 0. If you want to learn more look up a tkinter tutorial :)
  55.  
  56. nameL = Label(f4, text='New Username: ') # This just does the same as above, instead with the text new username.
  57. pwordL = Label(f4, text='New Password: ') # ^^
  58. nameL.grid(row=3, column=0, sticky=W) # Same thing as the instruction var just on different rows. :) Tkinter is like that.
  59. pwordL.grid(row=4, column=0, sticky=W) # ^^
  60.  
  61. nameE = Entry(f4) # This now puts a text box waiting for input.
  62. pwordE = Entry(f4, show='*') # Same as above, yet 'show="*"' What this does is replace the text with *, like a password box :D
  63. nameE.grid(row=3, column=1) # You know what this does now :D
  64. pwordE.grid(row=4, column=1) # ^^
  65.  
  66. signupButton = Button(f4, text='Signup', command=FSSignup) # This creates the button with the text 'signup', when you click it, the command 'fssignup' will run. which is the def
  67. signupButton.grid(columnspan=2, sticky=W)
  68. roots.mainloop() # This just makes the window keep open, we will destroy it soon
  69.  
  70. ArootA = Tk() # This now makes a new window.
  71. ArootA.geometry('1280x720')
  72. ArootA.title('Admin login') # This makes the window title 'login'
  73.  
  74. f1 = Frame(width=200, height=200, background="#D3D3D3")
  75. f2 = Frame(ArootA, width=400, height=200)
  76.  
  77. f2.pack(fill='both', expand=True, padx=0, pady=0, side = TOP)
  78. #f2.place(in_=f1, anchor="c", relx=.5, rely=.5)
  79. f3 = Frame(ArootA, width=550, height=450)
  80. f3.pack(fill='both', expand=True, padx=0, pady=0, side = TOP)
  81. f4 = Frame(ArootA, width=550, height=450)
  82. f4.pack(fill='both', expand=True, padx=0, pady=0, side = TOP)
  83.  
  84. adminLogin()
  85.  
  86. ArootA.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement