问题描述
我一直在为自己开发一个笔记程序,它运行良好,但是我在使用 .pack()
将所有小部件放置在我想要的位置时遇到了很多问题或 .grid()
选项.
I have been working on a note taking program for myself and it is going well however I have had a lot of problems with getting all my widgets placed where I want them using the .pack()
or .grid()
options.
环顾四周后,我发现我可以改用 .place()
选项.在我决定使用 .place()
之前,我发现无数论坛帖子说不要使用 .place()
!".
After looking around I found that I could use the .place()
option instead. Before I decided to use .place()
I found countless forum post saying "don't use .place()
!".
我对其他选项束手无策,所以我决定尝试一下 .place()
.结果证明 .place()
正是我解决布局问题所需要的,我只是不明白为什么每个人都如此讨厌 .place()
.
I was at a stand still with my other options so I decided to give .place()
a try. It turns out .place()
is exactly what I needed to fix my layout issues and I just don't understand why everyone is hating on .place()
so much.
.place()
是否存在固有的错误?或者人们只是出于一些实际原因而不是易用性而更喜欢使用 .pack()
和 .grid()
?
Is there something inherently wrong with .place()
? Or do people just prefer to use .pack()
and .grid()
for some practical reason other than ease of use?
推荐答案
.place
没有什么问题,尽管使用了 grid
和 pack
> 为您提供更多可维护的代码.例如,如果您想添加一个功能,place
将要求您更改绝对位置的负载以适应按钮.
There's nothing really wrong with .place
, although using grid
and pack
give you more maintainable code. If you want to add a feature then place
would require you to alter loads of absolute placements to fit a button in, for example.
如果你需要使用它然后使用它,它没有真正的问题,它只是不是许多问题的最易于维护的解决方案.正如你所说,这是一个偏好和易用性的问题.
If you need to use it then use it, there's no real problem with it, it just isn't the most maintainable solution to many problems. As you say, it's a matter of preference and ease of use.
您可以在此处阅读一个很好的答案.
there's an excellent answer you can read about it here.
这篇关于为什么人们说“不要使用 place()"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!