各位高手,小弟最近自學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發生甚麼問題了嗎....?
要怎麼解決