Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. import tkinter
  2. import sqlite3
  3.  
  4. connection = sqlite3.connect('project.db')
  5. cursor = connection.cursor()
  6.  
  7. cursor.execute('''CREATE TABLE users(username STRING, password STRING)''')
  8.  
  9. def Is_Valid():
  10. UsernameValidity=UserName_Entry.get()
  11. PasswordValidity=Password_Entry.get()
  12. cursor.execute('''SELECT password FROM users WHERE username = ?''', (UsernameValidity,))
  13. Is_Valid = cursor.fetchone()
  14. if PasswordValidity == Is_Valid:
  15. print (" One of the accounts have successfully logged in ")
  16. PasswordWrongText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
  17. else:
  18. print (" One of the accounts inputted the wrong credentials! ")
  19. PasswordWrongText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
  20.  
  21. def Close_Application():
  22. myGUI.destroy()
  23. exit()
  24.  
  25. myGUI = tkinter.Tk()
  26. myGUI.title("Gym Application Project")
  27. myGUI.geometry("500x300")
  28. myGUI.config(bg="#a1dbcd")
  29. myGUI.resizable(width=False, height=False)
  30.  
  31. UserName = tkinter.Label(myGUI,
  32. text="Username",
  33. bg="#a1dbcd",
  34. font=15)
  35. UserName.pack()
  36. UserName.place(x=10,y=20)
  37.  
  38. UserName_Entry = tkinter.Entry(myGUI,
  39. fg="black",
  40. relief="groove",
  41. width=25,
  42. font=("verdana",10),
  43. highlightthickness=1,
  44. highlightbackground="black",
  45. textvariable=())
  46. UserName_Entry.pack()
  47. UserName_Entry.place(x=10,y=40)
  48.  
  49. Password = tkinter.Label(myGUI,
  50. text="Password",
  51. bg="#a1dbcd",
  52. font=15)
  53. Password.pack()
  54. Password.place(x=10,y=80)
  55.  
  56. Password_Entry = tkinter.Entry(myGUI,
  57. fg="black",
  58. show='*',
  59. relief="groove",
  60. width=25,
  61. font=("verdana",10),
  62. highlightthickness=1,
  63. highlightbackground="black",
  64. textvariable=())
  65. Password_Entry.pack()
  66. Password_Entry.place(x=10,y=100)
  67.  
  68. PasswordWrongText = tkinter.Label(myGUI,
  69. font=("verdana", 10),
  70. bg="#a1dbcd")
  71.  
  72. PasswordWrongText.place(x=10,y=140)
  73.  
  74. Login_Button = tkinter.Button(myGUI,
  75. text="Login",
  76. bg="snow",
  77. relief="sunken",
  78. width=20,
  79. font=("verdana", 10),
  80. highlightthickness=2,
  81. command=Is_Valid)
  82. Login_Button.pack()
  83. Login_Button.place(x=10, y=260)
  84. Exit_Button = tkinter.Button(myGUI,
  85. text="Exit",
  86. bg="snow",
  87. relief="sunken",
  88. width=20,
  89. font=("verdana", 10),
  90. highlightthickness=2,
  91. command=Close_Application)
  92. Exit_Button.pack()
  93. Exit_Button.place(x=320,y=260)
  94.  
  95. myGUI.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement