![](/img/trans.png)
[英]Python 3: Tkinter: How to change Entry.get() into an integer
[英]Entry.get() Error in Python Tkinter
我试图在插入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()
我将非常感谢您的帮助; 谢谢!
确保您没有类似以下内容的行:
entry = Entry().pack() # entry is None
pack
, grid
, place
不会返回None
。 entry
变为None
。
您应该分开Entry
并调用pack
/ grid
/ place
方法:
entry = Entry()
entry.pack()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.