[英]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.