通过 Tkinter 更改标签上文本的大小 [英] Change size of text on label by Tkinter

查看:130
本文介绍了通过 Tkinter 更改标签上文本的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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)

heightwidth 参数改变了标签本身的大小,它们不影响字体.

The height and width arguments are changing the size of the label itself, they do not affect the font.

这篇关于通过 Tkinter 更改标签上文本的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆