Guest User

Untitled

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