【问题标题】:how to get the list of the available fonts on Tkinter? [duplicate]如何获取 Tkinter 上可用字体的列表? [复制]
【发布时间】:2021-03-20 04:37:03
【问题描述】:

如何获取 Tkinter 中可用字体的名称列表?

我尝试和使用的唯一字体是“Courier”和“Helvetica”,我尝试使用其他字体但它返回相同的默认字体。

# this works
button = tk.Button(self.subframe, text="quit", command=master.destroy,
                        highlightbackground='black', font='Helvectica 18')

# this does not work (the text remains the font)
button = tk.Button(self.subframe, text="quit", command=master.destroy,
                        highlightbackground='black', font='Roboto 18')

(font used in the second example)

所以我不知道哪些字体可用或不可用,如果我能得到字体列表会很有帮助。

【问题讨论】:

标签: python tkinter tk


【解决方案1】:

你可以这样做

from tkinter import Tk, font
root = Tk()
print(font.families())

【讨论】:

  • 我试过了,但它没有在终端返回任何东西和一个空白框架?
  • @coder_not_found: 做print(font.families()).
猜你喜欢
  • 2016-02-26
  • 2011-07-10
  • 1970-01-01
  • 1970-01-01
  • 2011-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多