我本来想做个口算题卡,然后加上时间效果
但是现在不仅没有显示,点击叉叉关闭程序时还崩溃
#时间代码
def clock():
global time1
time1=True
t1=time()
while time1:
now=time()-t1
time_1=t.Label(w,text=now,font=('img/i.ttf',20))
time_1.pack()
def clock_end():
global time1
time1=False
w=t.Tk()
w.geometry("1400x788")
w.resizable(False,False)
w.title('加减法口算题卡')
lab=t.Label(w,text='分数:',font=('img/i.ttf',20))
lab.place(x=1200,y=10)
button=Button(w,text='生成算式',command=lambda:[random(),clock() ])
button.pack()
m=Button(w,text='评分',command=lambda:[pf(),clock_end() ])
m.pack()
photo=t.PhotoImage(file="img/bg.png")
bg=t.Label(w,image=photo,compound = t.CENTER)
bg.pack()
w.mainloop()
错误信息:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Python37\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "D:\tctm\Aptana Studio 3 Workspace\Python\比赛\English.py", line 149, in <lambda>
button=Button(w,text='生成算式',command=lambda:[random(),clock() ])
File "D:\tctm\Aptana Studio 3 Workspace\Python\比赛\English.py", line 136, in clock
time_1=t.Label(w,text=now,font=('img/i.ttf',20))
File "D:\Python37\lib\tkinter\__init__.py", line 2763, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "D:\Python37\lib\tkinter\__init__.py", line 2296, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: can't invoke "label" command: application has been destroyed