关于tkinter的,莫名错误
Exception in Tkinter callbackTraceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\Administrator\Desktop\数据库\1.2.py", line 189, in <lambda>
editmenu.add_command(label="创建", command=lambda:new(self.win, conn))
File "C:\Users\Administrator\Desktop\数据库\1.2.py", line 102, in new
ttk.Button(newtp, text='确定', command = newtp.destroy())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\ttk.py", line 614, in __init__
Widget.__init__(self, master, "ttk::button", kw)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\ttk.py", line 559, in __init__
tkinter.Widget.__init__(self, master, widgetname, kw=kw)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: bad window path name ".!toplevel"
这是什么原因啊 把代码发上来。 zltzlt 发表于 2020-1-1 12:21
把代码发上来。
#新建成绩
def new(conn):
newtp = Toplevel()
newtp.geometry('300x500+200+200')
Label(newtp, text='学号:').pack()
sto = ttk.Entry(newtp)
sto.pack()
Label(newtp, text='学科号:').pack()
sc = ttk.Entry(newtp)
sc.pack()
Label(newtp, text='分数:').pack()
gr = ttk.Entry(newtp)
gr.pack()
cursor = conn.cursor()
cursor.execute("""
use stsc
INSERT INTO score VALUES ('777','377','772')
""" )
conn.commit()
ttk.Button(newtp, text='确定', command = newtp.destroy())
newtp.mainloop
这是截取错的这一部分小代码 我是做一个数据库学生管理系统 应该这样:
#新建成绩
def new(conn):
newtp = Toplevel()
newtp.geometry('300x500+200+200')
Label(newtp, text='学号:').pack()
sto = ttk.Entry(newtp)
sto.pack()
Label(newtp, text='学科号:').pack()
sc = ttk.Entry(newtp)
sc.pack()
Label(newtp, text='分数:').pack()
gr = ttk.Entry(newtp)
gr.pack()
cursor = conn.cursor()
cursor.execute("""
use stsc
INSERT INTO score VALUES ('777','377','772')
""" )
conn.commit()
ttk.Button(newtp, text='确定', command = newtp.destroy)
newtp.mainloop() zltzlt 发表于 2020-1-1 13:49
应该这样:
哇原来这么简单 谢谢啦{:5_100:}
页:
[1]