為什麼這篇tkinter範例鄉民發文收入到精華區:因為在tkinter範例這個討論話題中,有許多相關的文章在討論,這篇最有參考價值!作者aegisaaakhkh (8888C885)看板Python標題[問題] tkinter的la...
各位高手,小弟最近自學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發生甚麼問題了嗎....?
要怎麼解決
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.16.134 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1559467938.A.1C2.html