各位高手,小弟最近自学tkinter,在按照网上范例输入code如下:
import tkinter as tk
window = tk.Tk()
window.title('my window')
window.geometry('200x100')
window.mainloop()
l = tk.Label(window,
text='OMG! this is TK!',
bg='green',
font=('Arial', 12),
width=15, height=2
)
l.pack()
执行时虽然有跑出视窗,但label并没有显示出来,关闭时出现下方问题:
Traceback (most recent call last):
File ".\tk1.py", line 13, in <module>
width=15, height=2
File
"C:\Users\f2101\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py",
line 2766, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File
"C:\Users\f2101\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py",
line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: can't invoke "label" command: application has been
destroyed
想请教各位大神,我的tkinter发生什么问题了吗....?
要怎么解决