I am trying to make a sign in window for an application with tkinter and sqlite3 but all it sends to the data base repeatedly is that the username is ".!toplevel.!entry" and password is ".!toplevel.!entry2". Please help thanks
def createlogin():
global username
global password
top= Toplevel()
top.title("SmartCards - New User")
top.iconbitmap(r"C:\Users\Ethan\Documents\Comp NEA\Icon.ico")
top.config(padx=50, pady=50, bg=BACKGROUND_COLOR)
def submit1():
c.execute("INSERT INTO login (username, password) VALUES (?, ?)", ("username, password,"),)
conn.commit()
username = Entry(top)
username.insert(0,"Username: ")
username.grid(row=0, column=0)
username=str(username)
password = Entry(top)
password.insert(0,"Password: ")
password.grid(row=1, column=0)
password=str(password)
submit = Button(top, text="Submit", command=submit1)
submit.grid(row=2, column=0)
There are few issues in your code:
username = str(username)will setusernameto the name of the entry widgetusername. Same forpassword."username, password,"as the second argument ofc.execute()which raises exception because a tuple/list of two items is expectedglobal ...is not necessaryNote also that you should get the contents of the entry boxes inside
submit1()instead.Below is the modified code: