Python 使用按钮参数将数据插入sqlite时';命令';

Python 使用按钮参数将数据插入sqlite时';命令';,python,sqlite,tkinter,Python,Sqlite,Tkinter,您好当我尝试向sqlite插入数据时,会出现一个错误,并且按钮从框架中消失。问题出现在这两个函数中def fitcher(insertFun):和def insertFun(self) 下面是错误消息 C:\Users\issba\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/issba/Desktop/workstation/familyLibrary/mainGui.py Exception in Tkin

您好当我尝试向sqlite插入数据时,会出现一个错误,并且按钮从框架中消失。问题出现在这两个函数中
def fitcher(insertFun):
def insertFun(self)

下面是错误消息

    C:\Users\issba\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/issba/Desktop/workstation/familyLibrary/mainGui.py
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\issba\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1550, in __call__
    return self.func(*args)
  File "C:/Users/issba/Desktop/workstation/familyLibrary/mainGui.py", line 121, in insertFun
    new.submit = ttk.Button(new, text="insert data", command = new.fitcher)
AttributeError: 'Toplevel' object has no attribute 'fitcher'

Process finished with exit code 0

在我看来,你错过了很多东西 首先你需要这个函数

new.wait_window()
return (new.varb..etc)
你需要加上这个

new.conn.commit()
new.conn.close()
此函数您必须更改缩进,将其从该函数中取出
\uuuu init\uuuu

def insertFun():
您必须使用此函数获取数据

textvariable = new.locationGet
比如说

new.locationGet = tk.StringVar()
new.locationFiled = ttk.Entry(new, width=90, justify = CENTER,textvariable = new.locationGet)
new.locationFiled.pack()

另外,请更改属性。只需阅读此页面,它就非常适合您的问题

尝试将
new.fitcher
更改为
self.fitcher
。AttributeError:“mainGui”对象没有属性“BookTitle”这是错误消息的一部分将
self.fitcher
更改为
lambda x=new:self.fitcher(x)
和function
def fitcher(insertFun)
def fitcher(self,insertFun)
。没有任何类型的错误消息,但数据没有插入到sqlite表中谢谢你的帮助谢谢你的帮助谢谢我从同一链接做了,但它在这个网站上
new.locationGet = tk.StringVar()
new.locationFiled = ttk.Entry(new, width=90, justify = CENTER,textvariable = new.locationGet)
new.locationFiled.pack()