问题描述
我在 Windows 位 64 上使用 Tkinter v2.x.
I am using Tkinter v2.x on Windows bit-64.
我的问题是,如何更改 Label
小部件上文本的大小?
My question is, how to change the size of the text on the Label
widget?
例如:
label = tk.Label( root, text="PASS", bg="green", fg="black", font=2, height=50, width = 50)
我做了大量研究并遵循了这个教程,我注意到无论我如何修改字体、高度或宽度",标签都可以放大或缩小,但无法更改标签
上的文字大小.
I did a bunch of research and followed this tutorial, and I noticed that no matter how I modify the "font, height or width", the label could be enlarged or shrunk but the size of text on the Label
could not be changed.
推荐答案
font
参数采用最多 3 个成员的元组 (family, size, style)
你可以省略家庭并像这样简单地改变大小:
The font
argument takes a tuple with up to 3 members (family, size, style)
You can omit the family and simply change the size like this:
label = Label(root, text="PASS", bg="green", fg="black", font=(None, 15), height=50, width=50)
height
和 width
参数改变了标签本身的大小,它们不影响字体.
The height
and width
arguments are changing the size of the label itself, they do not affect the font.
这篇关于通过 Tkinter 更改标签上文本的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!