-1

This is the error I get :

Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Users\Denis\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
        return self.func(*args)
      File "C:\Users\Denis\Desktop\Python\Sunday Work.py", line 47, in <lambda>
        RegistrationButton = Button(userRegister,text="Register",font=("monaco", 10),width=30,relief="groove",command=lambda: accountRegister(RegistrationUsernameEntry.get(),RegistrationPasswordEntry.get())).place(x=26,y=230)
    AttributeError: 'NoneType' object has no attribute 'get'

I'm making a user account login & registration system - within the code above I made a function and within it I made a toplevel to open a new window when clicking register button on the login screen. I set up the connection to sql & created a cursor, etc, but every time I insert something within the entries I made and click 'register' I get this error. Any ideas what might be wrong?

This is some of its code

def userRegister():
    userRegister = Toplevel(root, bg="#a1dbcd")
    userRegisterTitle = userRegister.title("Registration")
    userRegister.geometry("300x300")
    userRegister.resizable(width=False, height=False)
    #Creates userRegister window content to register
    RegistrationForm = Label(userRegister,text="REGISTRATION FORM",bg="#a1dbcd",font=("monaco", 20)).pack()
    RegistrationFormDesign = Label(userRegister,bg="black",width=50).pack()
    RegistrationFormInfo = Label(userRegister,text="To create an account fill in the form . . ",bg="#a1dbcd",font=("monaco", 9)).pack()
    RegistrationUsername = Label(userRegister,text="Username:",bg="#a1dbcd",font=("monaco", 12)).place(x=10,y=100)
    RegistrationUsernameEntry = Entry(userRegister,fg="black",relief="groove",width=20,font=("monaco", 10),highlightthickness=1,highlightbackground="black").place(x=10,y=130)
    RegistrationPassword = Label(userRegister,text="Password:",bg="#a1dbcd",font=("monaco", 12)).place(x=10,y=160)
    RegistrationPasswordEntry = Entry(userRegister,fg="black",relief="groove",show='*',width=20,font=("monaco", 10),highlightthickness=1,highlightbackground="black").place(x=10,y=190)
    *RegistrationButton = Button(userRegister,text="Register",font=("monaco", 10),width=30,relief="groove",command=lambda: accountRegister(RegistrationUsernameEntry.get(),RegistrationPasswordEntry.get())).place(x=26,y=230)*
    CloseButton = Button(userRegister,text="Close",font=("monaco", 10),width=30,relief="groove",command=userRegister.destroy).place(x=26,y=265)

#Stores data inputted within entries as well as displaying a message when done
def accountRegister(UsernameRegister,PasswordRegister):
    print(UsernameRegister,PasswordRegister)
    cursor.execute('''INSERT INTO users(username, password)VALUES(?, ?)''',(UsernameRegister, PasswordRegister))
    messagebox.showinfo("Account Registration Info", " Account is now registered! ")
R. Gadeev
  • 188
  • 3
  • 12
sago
  • 11
  • 5

1 Answers1

0

I fixed it by placing .pack or .place under each one.

e.g.

[code here] [name].pack

sago
  • 11
  • 5