如何放置框架

How to Place a frame

我是 Tkinter 和 Python 的新手,从 this Code as a baseline, I'd Like to Place the Button Frame for navigation to the different pages slightly raised from the bottom (inside this 开始工作。

那么我如何才能将框架放置在该特定坐标处,或者将其网格化到右下角,以便在不妨碍页面的情况下填充它?

如果您只想将它​​从顶部边框移开,只需使用填充即可。

buttonframe.pack(side="top", fill="x", expand=False, pady=15)

如果你想让它出现在右下角,那么在容器之后打包按钮。

container.pack(side="top", fill="both", expand=True)
buttonframe.pack(side="right", fill="x", expand=False, pady=15)

您还可以使用 .pack 以外的其他命令,例如 .grid grid or .place place。我个人更喜欢混合使用 .grid.pack

正如@stovli 所提到和支持的那样,我发现最好的解决方案是切掉框架的底部并将其拆分为自己的框架,然后简单地将其放在另一个框架的下方。这导致设计更简单,而不是在彼此之上管理框架。