简体   繁体   English

如何在我的 PySimpleGUI 桌面应用程序中使用 Google 字体?

[英]How can I use Google Fonts in my PySimpleGUI desktop application?

Is there a way to use Google Fonts in my PySimpleGUI desktop application ?有没有办法在我的 PySimpleGUI 桌面应用程序中使用 Google 字体 Or is there any Python built-in packages to use Google Fonts in my code?或者是否有任何 Python 内置包可以在我的代码中使用 Google 字体? If there is, how can I replace the fonts of the (Button or Text) elements in PySimpleGUI with the imported module's Google Fonts?如果有,如何用导入模块的 Google 字体替换 PySimpleGUI 中(按钮或文本)元素的字体? And also I found out that there are several fonts available in PySimpleGUI ( Helvetica , Courier , Times , Arial ...), but I want to see the whole list of available fonts in PySimpleGUI?而且我还发现 PySimpleGUI 中有几种可用字体( HelveticaCourierTimesArial ...),但我想查看 PySimpleGUI 中可用字体的完整列表?

The list of available fonts is dependent upon the GUI framework you're running on as well as the operating system.可用字体列表取决于您运行的 GUI 框架以及操作系统。

There is a demo that is in the Demo Programs area on the PySimpleGUI GitHub named "Font Previewer" that gets the list of available fonts and previews them.在 PySimpleGUI GitHub 上的 Demo Programs 区域中有一个名为“Font Previewer”的演示,用于获取可用字体列表并对其进行预览。

It calls tkinter directly to get the list of fonts as it's not a feature implemented in PySimpleGUI at this point.它直接调用 tkinter 来获取字体列表,因为此时它不是 PySimpleGUI 中实现的功能。 No one has ever requested it.从来没有人要求过。

Here is the code used in the demo that gets the list of fonts and puts it into the variable fonts这是演示中使用的代码,用于获取字体列表并将其放入变量fonts

from tkinter import font
import tkinter
root = tkinter.Tk()
fonts = list(font.families())
fonts.sort()
root.destroy()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM