Reputation: 77
Is there a way to use Google Fonts in my PySimpleGUI desktop application? Or is there any Python built-in packages to use Google Fonts in my code? If there is, how can I replace the fonts of the (Button or Text) elements in PySimpleGUI with the imported module's Google Fonts? 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?
Upvotes: 4
Views: 4720
Reputation: 5754
The list of available fonts is dependent upon the GUI framework you're running on as well as the operating system.
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.
It calls tkinter directly to get the list of fonts as it's not a feature implemented in PySimpleGUI at this point. 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
from tkinter import font
import tkinter
root = tkinter.Tk()
fonts = list(font.families())
fonts.sort()
root.destroy()
Upvotes: 2