我嘗試瞭解tkinter的工作原理。我有這個簡單的程序:如何使用tkinter自定義框架
import tkinter as tk
class Application:
def __init__(self, master):
frame = tk.Frame(master, height=100, width=500, bg="#FFFFFF", bd=10)
frame.grid()
self.button = tk.Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.grid()
root = tk.Tk()
app=Application(root)
root.mainloop()
當我運行該程序,我得到一個窗口
,但我爲框架指定的選項(高度,寬度...)不工作。我的錯誤在哪裏?感謝您的幫助。
'grid_propagate'對於正在學習tkinter的人來說是個不好的建議。這幾乎從來都不是適當的解決方案。 –