Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 593
hkam Avatar asked Oct 24 '25 14:10

hkam


1 Answers

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()
like image 85
Mike from PSG Avatar answered Oct 27 '25 06:10

Mike from PSG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!