-1
以内に「取得」は属性を持っていない:はAttributeError:「NoneType」オブジェクトは、これは私が取得エラーであるのTkinter&パイソン3.6
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'
私は、ユーザーアカウントのログイン&登録システムを作ってるんだ - 上記のコード内私は機能を作って、その中でログイン画面の登録ボタンをクリックするとトップレベルになった。私は&のSQLへの接続を設定してカーソルなどを作成しましたが、私が作成したエントリに何かを挿入し、「登録」をクリックするたびにこのエラーが発生します。どのようなアイデアが間違っているかもしれない?
これは私がそれぞれ下.pack又は.placeを置くことによってそれを修正し、そのコード
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! ")
.pack。 [コードはこちら] [名前] .pack – sago