How to create equal-width columns in Python 2.7 with Tkinter

浪子不回头ぞ 提交于 2019-11-27 02:15:57

To make a gridded layout have all columns have the same width, you've got to configure those columns to have the same weight and to be in the same uniform group. This configuration is associated with the master widget, not any of the contained widgets (because columns can contain many widgets, of course).

In standard Tk, this is done with:

# "fred" is just some arbitrary key; it means nothing other than to name the group
grid columnconfigure $master 0 -weight 1 -uniform fred

In Tkinter (note that uniform seems to be not documented in the docstring but it is exactly what you need):

# "fred" is just some arbitrary key; it means nothing other than to name the group
master.grid_columnconfigure(0, weight=1, uniform="fred")

Then repeat for the other column indices that you want to set things for. (As you can see, the code's very similar in these two cases.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!