|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- Exception in Tkinter callback
- Traceback (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"
复制代码
这是什么原因啊
应该这样:
- #新建成绩
- 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()
复制代码
|
|