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