Get a list of all available fonts in Tkinter

Here we are going to write code about get a list of all available fonts in tkinter. tkinter provides a range of fonts for displaying text in widgets. The available fonts vary depending on the platform. You can specify font families, styles, size.

we can easily unserstand the concept and get logic easily.

 ALGORITHM

  • Import necessary library (Tkinter).
  • Create main window (window).
  • Set window geometry (800×500).
  • Initialize variable m with message (“hi you clicked me …!”)
  • Define function yellow(m) to print message m.
  •  Create button with label (“HELLO! Click ME YAR”) and command yellow(m) using lambda function.
  • Add button to main window using pack().
  • Start main event loop (window.mainloop()).

                               SOURCE CODE

 import tkinter as tk
window=tk.Tk()
window.geometry("800x500")
def yellow(m):
    print(m)
m="hi you  clicked me ...!"    
button=tk.Button(window,text="HELLO! Click ME YAR",command=lambda: yellow(m))
button.pack()
window.mainloop()

OUTPUT

hi you clicked me ...!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top