列出 `tkinter` 中可用的字体系列 [英] List available font families in `tkinter`

查看:41
本文介绍了列出 `tkinter` 中可用的字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多可用的 tkinter 示例中,您可能会看到以下内容:

In many tkinter examples available out there, you may see things like:

canvas.create_text(x, y, font=('Helvetica', 12), text='foo')

但是,这在您的计算机上运行时可能不起作用(结果将完全忽略字体参数).显然,如果 font 参数中有任何不正确的值,它会被忽略.

However, this may not work when run in your computer (the result would completely ignore the font parameter). Aparently, the font parameter is ignored if there is any incorrect value in it.

为了检查字体系列是否有效,我如何列出系统中所有可用的字体?

In order to check if the font family is valid, how can I list all available in my system?

推荐答案

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

这篇关于列出 `tkinter` 中可用的字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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