[英]Python tkinter font do not change
我无法更改标签的字体。
from tkinter import *
nc = Tk()
#LABEL cognome
cognome_l=Label(nc, text="cognome",
font=('Ubuntu 20'))
cognome_l.grid(row=0,column=0,sticky='E',padx=5, pady=5)
#LABEL cognome
cognome_l=Label(nc, text="cognome",
font=('Verdana 20'))
cognome_l.grid(row=1,column=0,sticky='E',padx=5, pady=5)
nc.mainloop()
这两个标签应该不同,但它们是相同的,并且文本看起来很模糊。 我该如何解决? 谢谢
编辑:这就是我得到的: https://drive.google.com/file/d/1UcIqr5itZhrTMkspytwbPmLTiQwbhnga/view?usp=sharing
你应该写font = ('Verdana', 20)
尽管font = ('Verdana 20')
cognome_l = Label(nc, text="cognome", font="Times 15")
您需要像这样指定字体的属性:
“
fontname
fontsize
”“快递 14”
已编辑
我使用带有 python 解释器的 sublime 文本执行了您的程序代码。 我的电脑上安装了 Verdana 字体,但没有安装 Ubuntu 字体。
Verdana 在 Microsoft Word 和 Python 上的结果几乎相同。 我没有 Ubuntu 字体,这就是为什么它在 python 中显示默认字体的原因。 所以我想也许你没有安装 Verdana 和 Ubuntu fonts。
问题是我使用的是 conda 环境
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.