为了使网格布局的所有列都具有相同的宽度,必须将这些列配置为具有相同的权重并处于相同的统一组中。此配置与主窗口小部件相关联,而不与所包含的任何窗口小部件相关联(因为列当然可以包含许多窗口小部件)。
在标准Tk中,这可以通过以下方式完成:
# "fred" is just some arbitrary key; it means nothing other than to name the groupgrid columnconfigure $master 0 -weight 1 -uniform fred
在Tkinter中(请注意,文档字符串中
uniform似乎没有记录此文件,但这正是您所需要的):
# "fred" is just some arbitrary key; it means nothing other than to name the groupmaster.grid_columnconfigure(0, weight=1, uniform="fred")
然后,对要为其设置内容的其他列索引重复上述步骤。(如您所见,这两种情况下的代码 非常 相似。)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)