Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- import sqlite3
- connection = sqlite3.connect('workingBench.db')
- cursor = connection.cursor()
- def Is_Valid():
- UsernameValidity=UserName_Entry.get()
- PasswordValidity=Password_Entry.get()
- cursor.execute('''SELECT password FROM users WHERE username = ?''', (UsernameValidity,))
- Is_Valid = cursor.fetchone()
- if PasswordValidity == Is_Valid:
- print (" One of the accounts have successfully logged in ")
- PasswordWrongText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
- else:
- print (" One of the accounts inputted the wrong credentials! ")
- PasswordWrongText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
- cursor.commit()
- cursor.close()
- def Account_Register():
- UsernameRegister=RegistrationUsernameEntry.get()
- PasswordRegister=RegistrationPasswordEntry.get()
- cursor.execute('''INSERT INTO users(username, password)VALUES(?, ?)''',str[username[0]], str[password[1]])
- def Close_Application():
- myGUI.destroy()
- exit()
- def NewWindow():
- NewWindow = tkinter.Toplevel(myGUI,
- bg="#a1dbcd")
- NewWindowTitle = NewWindow.title("Registration Window")
- NewWindow.geometry('300x300')
- NewWindow.resizable(width=False, height=False)
- RegistrationForm = tkinter.Label(NewWindow,
- text="REGISTRATION FORM",
- bg="#a1dbcd",
- font=("monaco", 20))
- RegistrationForm.pack()
- RegistrationFormDesign = tkinter.Label(NewWindow,
- bg="black",
- width=50)
- RegistrationFormDesign.pack()
- RegistrationFormInfo = tkinter.Label(NewWindow,
- text="To create an account fill in the form . . ",
- bg="#a1dbcd",
- font=("monaco", 9))
- RegistrationFormInfo.pack()
- RegistrationUsername = tkinter.Label(NewWindow,
- text="Username:",
- bg="#a1dbcd",
- font=("monaco", 12))
- RegistrationUsername.pack()
- RegistrationUsername.place(x=10, y=100)
- RegistrationUsernameEntry = tkinter.Entry(NewWindow,
- fg="black",
- relief="groove",
- width=20,
- font=("monaco", 10),
- highlightthickness=1,
- highlightbackground="black")
- RegistrationUsernameEntry.pack()
- RegistrationUsernameEntry.place(x=10, y=130)
- RegistrationPassword = tkinter.Label(NewWindow,
- text="Password:",
- bg="#a1dbcd",
- font=("monaco", 12))
- RegistrationPassword.pack()
- RegistrationPassword.place(x=10, y=160)
- RegistrationPasswordEntry = tkinter.Entry(NewWindow,
- fg="black",
- relief="groove",
- width=20,
- font=("monaco", 10),
- highlightthickness=1,
- highlightbackground="black")
- RegistrationPasswordEntry.pack()
- RegistrationPasswordEntry.place(x=10, y=190)
- RegistrationButton = tkinter.Button(NewWindow,
- text="Register",
- font=("monaco", 10),
- width=30,
- relief="groove")
- RegistrationButton.pack()
- RegistrationButton.place(x=26, y=265)
- myGUI = tkinter.Tk()
- myGUI.title("Gym Application Project")
- myGUI.geometry("500x300")
- myGUI.config(bg="#a1dbcd")
- myGUI.resizable(width=False, height=False)
- UserName = tkinter.Label(myGUI,
- text="Username :",
- bg="#a1dbcd",
- font=15)
- UserName.pack()
- UserName.place(x=10,y=20)
- UserName_Entry = tkinter.Entry(myGUI,
- fg="black",
- relief="groove",
- width=25,
- font=("verdana",10),
- highlightthickness=1,
- highlightbackground="black",
- textvariable=())
- UserName_Entry.pack()
- UserName_Entry.place(x=10,y=40)
- Password = tkinter.Label(myGUI,
- text="Password :",
- bg="#a1dbcd",
- font=15)
- Password.pack()
- Password.place(x=10,y=80)
- Password_Entry = tkinter.Entry(myGUI,
- fg="black",
- show='*',
- relief="groove",
- width=25,
- font=("verdana",10),
- highlightthickness=1,
- highlightbackground="black",
- textvariable=())
- Password_Entry.pack()
- Password_Entry.place(x=10,y=100)
- PasswordWrongText = tkinter.Label(myGUI,
- font=("verdana", 10),
- bg="#a1dbcd")
- PasswordWrongText.place(x=10,y=140)
- Login_Button = tkinter.Button(myGUI,
- text="Login",
- bg="snow",
- relief="groove",
- width=20,
- font=("verdana", 10),
- command=Is_Valid)
- Login_Button.pack()
- Login_Button.place(x=10, y=260)
- Exit_Button = tkinter.Button(myGUI,
- text="Exit",
- bg="snow",
- relief="groove",
- width=20,
- font=("verdana", 10),
- command=Close_Application)
- Exit_Button.pack()
- Exit_Button.place(x=320,y=260)
- Register_Button = tkinter.Button(myGUI,
- text="REGISTER",
- bg="snow",
- relief="groove",
- width=8,
- font=("verdana", 10),
- command=NewWindow)
- Register_Button.pack()
- Register_Button.place(x=215,y=260)
- myGUI.mainloop()
Add Comment
Please, Sign In to add comment