Tkinter中的字符串对齐

Tkinter中的字符串对齐,第1张

Tkinter中的字符串对齐

您的代码没有问题。

问题在于您使用的是非单位长度的

non-monospace
字体,其中字符占用的空间不相同。

可以通过更改为如下

monospace
字体来解决
consolas

import tkFontmy_font = tkFont.Font(family='Consolas', size=15, weight='bold')# then plug in the font to your widget ...

所以在你的代码中,它就像

label_id = tkinter.Label(f, anchor=tkinter.W, text=sector_id, font=('Consolas', 15))label_name = tkinter.Label(f, anchor=tkinter.W, text=sector_name, font=('Consolas', 15))


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存