Guest User

Untitled

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