Guest User

Untitled

a guest
Mar 27th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. from tkinter import *
  2. import sqlite3
  3.  
  4. connection = sqlite3.connect('workingBench.db')
  5. cursor = connection.cursor()
  6.  
  7. def Is_Valid():
  8. UsernameValidity=UserName_Entry.get()
  9. PasswordValidity=Password_Entry.get()
  10. cursor.execute('''SELECT password FROM users WHERE username = ?''', (UsernameValidity,))
  11. Is_Valid = cursor.fetchone()
  12. if PasswordValidity == Is_Valid:
  13. print (" One of the accounts have successfully logged in ")
  14. IsValidText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
  15. else:
  16. print (" One of the accounts inputted the wrong credentials! ")
  17. IsValidText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
  18.  
  19. def Account_Register(UsernameRegister,PasswordRegister):
  20. print(UsernameRegister,PasswordRegister)
  21. cursor.execute('''INSERT INTO users(username, password)VALUES(?, ?)''',(UsernameRegister, PasswordRegister))
  22.  
  23. def Close_Application():
  24. myGUI.destroy()
  25. exit()
  26.  
  27. ## Creating Registration GUI using toplevel
  28. def NewWindow():
  29. NewWindow = Toplevel(myGUI,
  30. bg="#a1dbcd")
  31. NewWindowTitle = NewWindow.title("Registration Window")
  32. NewWindow.geometry('300x300')
  33. NewWindow.resizable(width=False, height=False)
  34.  
  35. RegistrationForm = Label(NewWindow,
  36. text="REGISTRATION FORM",
  37. bg="#a1dbcd",
  38. font=("monaco", 20))
  39. RegistrationForm.pack()
  40.  
  41. RegistrationFormDesign = Label(NewWindow,
  42. bg="black",
  43. width=50)
  44. RegistrationFormDesign.pack()
  45.  
  46. RegistrationFormInfo = Label(NewWindow,
  47. text="To create an account fill in the form . . ",
  48. bg="#a1dbcd",
  49. font=("monaco", 9))
  50. RegistrationFormInfo.pack()
  51.  
  52. RegistrationUsername = Label(NewWindow,
  53. text="Username:",
  54. bg="#a1dbcd",
  55. font=("monaco", 12))
  56.  
  57. RegistrationUsername.place(x=10,y=100)
  58.  
  59. RegistrationUsernameEntry = Entry(NewWindow,
  60. fg="black",
  61. relief="groove",
  62. width=20,
  63. font=("monaco", 10),
  64. highlightthickness=1,
  65. highlightbackground="black")
  66.  
  67. RegistrationUsernameEntry.place(x=10,y=130)
  68.  
  69. RegistrationPassword = Label(NewWindow,
  70. text="Password:",
  71. bg="#a1dbcd",
  72. font=("monaco", 12))
  73.  
  74. RegistrationPassword.place(x=10,y=160)
  75.  
  76. RegistrationPasswordEntry = Entry(NewWindow,
  77. fg="black",
  78. relief="groove",
  79. show='*',
  80. width=20,
  81. font=("monaco", 10),
  82. highlightthickness=1,
  83. highlightbackground="black")
  84.  
  85. RegistrationPasswordEntry.place(x=10,y=190)
  86.  
  87. RegistrationButton = Button(NewWindow,
  88. text="Register",
  89. font=("monaco", 10),
  90. width=30,
  91. relief="groove",
  92. command=lambda: Account_Register(RegistrationUsernameEntry.get(),RegistrationPasswordEntry.get()))
  93.  
  94. RegistrationButton.place(x=26,y=230)
  95.  
  96. CloseButton = Button(NewWindow,
  97. text="Close",
  98. font=("monaco", 10),
  99. width=30,
  100. relief="groove",
  101. command=NewWindow.destroy)
  102.  
  103. CloseButton.place(x=26,y=265)
  104.  
  105. ## Creating the main GUI
  106. myGUI = Tk()
  107. myGUI.title("Gym Application Project")
  108. myGUI.geometry("500x300")
  109. myGUI.config(bg="#a1dbcd")
  110. myGUI.resizable(width=False, height=False)
  111.  
  112. UserName = Label(myGUI,
  113. text="Username :",
  114. bg="#a1dbcd",
  115. font=15)
  116. UserName.pack()
  117. UserName.place(x=10,y=20)
  118.  
  119. UserName_Entry = Entry(myGUI,
  120. fg="black",
  121. relief="groove",
  122. width=25,
  123. font=("verdana",10),
  124. highlightthickness=1,
  125. highlightbackground="black",
  126. textvariable=())
  127.  
  128. UserName_Entry.place(x=10,y=40)
  129.  
  130. Password = Label(myGUI,
  131. text="Password :",
  132. bg="#a1dbcd",
  133. font=15)
  134.  
  135. Password.place(x=10,y=80)
  136.  
  137. Password_Entry = Entry(myGUI,
  138. fg="black",
  139. show='*',
  140. relief="groove",
  141. width=25,
  142. font=("verdana",10),
  143. highlightthickness=1,
  144. highlightbackground="black",
  145. textvariable=())
  146.  
  147. Password_Entry.place(x=10,y=100)
  148.  
  149. IsValidText = Label(myGUI,
  150. font=("verdana", 10),
  151. bg="#a1dbcd")
  152.  
  153. IsValidText.place(x=10,y=140)
  154.  
  155. Login_Button = Button(myGUI,
  156. text="Login",
  157. bg="snow",
  158. relief="groove",
  159. width=20,
  160. font=("verdana", 10),
  161. command=Is_Valid)
  162.  
  163. Login_Button.place(x=10,y=260)
  164.  
  165. Exit_Button = Button(myGUI,
  166. text="Exit",
  167. bg="snow",
  168. relief="groove",
  169. width=20,
  170. font=("verdana", 10),
  171. command=Close_Application)
  172.  
  173. Exit_Button.place(x=320,y=260)
  174.  
  175. Register_Button = Button(myGUI,
  176. text="REGISTER",
  177. bg="snow",
  178. relief="groove",
  179. width=8,
  180. font=("verdana", 10),
  181. command = NewWindow)
  182.  
  183. Register_Button.place(x=215,y=260)
  184.  
  185. myGUI.mainloop()
Add Comment
Please, Sign In to add comment