Advertisement
mygrace

Untitled

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