Python Tkinter Font Chooser
Tk (and Tkinter) doesn't have any font chooser in the default distribution. You'll need to create your own. Here is an example I found: Tkinter FontChooser
Note: Tk 8.6 will have a build in font chooser dialog: FontChooser
The basis for a simple font selector can be found below
import tkinter as tkfrom tkinter import fontdef 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 font in available_fonts: lbFonts.insert(tk.END, font)lbFonts.bind("<Double-Button-1>", changeFont)laExample = tk.Label(root,text="Click Font")laExample.grid()root.mainloop()
Double clicking on a font in the list will change the example text below to that font. You can scroll down through the list of fonts by using a mouse wheel (or you can add a scroll bar to it)
There is a font chooser window in tkinter but it has been discontinued in the newer versions but you can still access it.
l = ttk.Label(root, text="Hello World", font="helvetica 24")l.grid(padx=10, pady=10)def font_changed(font): l['font'] = fontroot.tk.call('tk', 'fontchooser', 'configure', '-font', 'helvetica 24', '-command', root.register(font_changed))root.tk.call('tk', 'fontchooser', 'show')
Check this link for more details: https://tkdocs.com/tutorial/windows.html