我正在尝试为正在处理的应用程序在框架上放置一个按钮......但是当我使用包或网格时框架消失了
from Tkinter import *
root=Tk()
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry(str(width)+'x'+str(height))
frame=Frame(root,width=500, height=500, bg='black')
but1=Button(frame,text='qwe')
but1.grid()
frame.grid()
root.mainloop()
如果我使用place,更糟糕的是,它们都消失了......我看不到Frame和Button
from Tkinter import *
root=Tk()
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry(str(width)+'x'+str(height))
frame=Frame(root,width=500, height=500, bg='black')
but1=Button(frame,text='qwe')
but1.place()
frame.place()
root.mainloop()
但是当我使用 pack_propagate(0) 时,我可以同时看到它们...
from Tkinter import *
root=Tk()
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry(str(width)+'x'+str(height))
frame=Frame(root,width=500, height=500, bg='black')
but1=Button(frame,text='qwe')
but1.pack()
frame.pack_propagate(0)
frame.pack()
root.mainloop()
我的问题是,
- pack_propagate(0) 是什么意思?
- 为什么框架在有和没有 pack_propagate(0) 的情况下表现得很奇怪?
- GRID和PLACE的 pack_propagate(0)等价物是什么?