怎样解决Tkinter中Frame嵌套导致外部Frame大小失灵问题?-灵析社区

超好看鸭

使用的是Python,tk,我如果在一个Frame中嵌套一个Frame,外面的Frame大小设置就失灵了。 ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241016/5b9a59239670ba3dcaade646a552d57d.png) import customtkinter if __name__ == "__main__": app = customtkinter.CTk() app.geometry("300x300") frame = customtkinter.CTkFrame(app, width=280, height=280, fg_color="red") frame_1 = customtkinter.CTkFrame( frame, width=20, height=20, fg_color="green", corner_radius=5 ) frame_1.pack() frame_2 = customtkinter.CTkFrame( frame, width=20, height=20, fg_color="blue", corner_radius=5 ) frame_2.pack() frame.pack() app.mainloop() 本来是想做一组小Frame在里面,然后更随窗口大小变化的。 m*n行,最后一行可能不填满这个样子。

阅读量:28

点赞量:0

问AI
一本正经写代码
这种问题搜得到吧, 在frame.pack()下加一行 frame.pack_propagate(0)