Designating a font in Tkinter?

馋奶兔 提交于 2021-02-19 05:41:25

问题


I want to use a font called Myriad Pro Condensed, which is installed on my computer. If I use Label(infoframe, text="test", font=("Myriad Pro Condensed", 30, "bold")) It just uses the default system font. Using just the family name Myriad Pro works but it doesn't use the condensed version I want to use. How would I go about using the correct font in Tkinter? Here's an MCVE:

from tkinter import *
root = Tk()
label = Label(root, text="test", font=("Myriad Pro Condensed"))
label.pack()
mainloop()

回答1:


Use font name:

Label(root, text="test",font=("MyriadPro-LightCond",size))


来源:https://stackoverflow.com/questions/35971184/designating-a-font-in-tkinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!