如何使用Tkinter在Python 2.7中创建等宽列

如何使用Tkinter在Python 2.7中创建等宽列,第1张

如何使用Tkinter在Python 2.7中创建等宽列

为了使网格布局的所有列都具有相同的宽度,必须将这些列配置为具有相同的权重并处于相同的统一组中。此配置与主窗口部件相关联,而不与所包含的任何窗口小部件相关联(因为列当然可以包含许多窗口小部件)。

在标准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")

然后,对要为其设置内容的其他列索引重复上述步骤。(如您所见,这两种情况下的代码 非常 相似。)



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5644060.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存