【发布时间】:2019-12-09 03:04:57
【问题描述】:
尝试定义一个删除函数,其中用户输入一个名称并单击删除按钮和包含数据的行在 python 中的 tkinter 和 sqlite 的帮助下删除。
这是我的删除功能:
def deleteMovie(name):
conn = sqlite3.connect('moviedata.db')
sql = "Delete from movies WHERE name=?"
conn.execute(sql,(name,))
messagebox.showinfo("information","MOVIE DELETED")
conn.commit()
conn.close()
#this is my entry
代码:
window = tk.Tk()
window.title("SP Movie Admin Form")
window.geometry("400x250")
window.resizable(0, 0)
lName = ttk.Label(window,text="Name",padding=2)
lName.grid(row=1,column=1,columnspan=1)
nameent = StringVar()
nameent = ttk.Entry(window,textvariable=nameent)
nameent.grid(row=1,column=2,columnspan=3)
这是我的按钮:
buttondelete = ttk.Button(window,text="Delete",command=deleteMovie)
buttondelete.grid(row=7,column=2)
window.mainloop()
这是错误
Traceback (most recent call last):
File "C:\Users\gayat\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: deleteMovie() missing 1 required positional argument: 'name'
【问题讨论】:
标签: python sqlite tkinter error-handling typeerror