Home > Net >  Generate a list of all available monospaced fonts
Generate a list of all available monospaced fonts

Time:06-18

Currently, I am using working code to generate a list of available fonts. However, I'd like to only show the list of avaliable monospaced (TkFixedFont)

from tkinter import font


def changeFont(event):
   selection = lbFonts.curselection()
   laExample.config(font=(available_fonts[selection[0]], "16"))

root = tk.Tk()
available_fonts = font.families()

lbFonts = tk.Listbox(root)
lbFonts.grid()

for fonts in available_fonts:
   lbFonts.insert(tk.END, fonts)

lbFonts.bind("<Double-Button-1>", changeFont)

laExample = tk.Label(root,text="Click Font")
laExample.grid()



root.mainloop()

CodePudding user response:

Each font has a screenshot

  • Related