当我插入ID或用户在输入框中输入配方名称时,我试图删除记录。但是,由于以下错误,它不会让我从输入框中获取信息:
"Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "H:\A-Level Computing\PROJECT!\Final Code.py", line 368, in delete_recipe
Retrieve1 = EntryBox1.get()
AttributeError: 'NoneType' object has no attribute 'get'"
代码如下:
def delete_recipe():
global EntryBox1, EntryBox2, new_db
Retrieve1 = EntryBox1.get()
Retrieve2 = EntryBox2.get()
new_db = sqlite3.connect('H:\A-Level Computing\PROJECT!\Recipes.db')
new_db.execute("DELETE from RecipesDetails WHERE Retrieve1 = Rec_ID and Retrieve2 = Name")
new_db.commit()
new_db.close()
我真的很感激任何帮助;谢谢!
答案 0 :(得分:1)
确保您没有以下行:
entry = Entry().pack() # entry is None
pack
,grid
,place
确实返回None
。 entry
成为None
。
您应该将Entry
创作与调用pack
/ grid
/ place
方法分开:
entry = Entry()
entry.pack()