In this tutorial, I will show you find list of all available fonts in Tkinter.
At first, I just had to import the Tkinter in my program pass. I am going to use the Tkinter name. I have written anu instead of Tkinter. It will save me time.
import tkinter as anu
So to do that just import it, we can write from tkinter import Tk, font. It has been imported, and now need to store all font names in a list.
import tkinter as anu from tkinter import Tk, font
Then I’ll have to create a variable. I am giving it nexWindow. This is the variable where I’ll be storing my window. we can write this nexWindow= anu. Tk(). Here nexWindow is the window that we create.
import tkinter as anu from tkinter import Tk, font nexWindow= anu.Tk()
We can do it like this, take a variable all font and store it in this variable. Creating a list method and in the list, we can simply write all_fonts= list(font.families()).
import tkinter as anu from tkinter import Tk, font nexWindow= anu.Tk() all_fonts= list(font.families())
If I can give a line space for each font name. We can do this easily for font_name in all_fonts:. And just print the elements one by one.
import tkinter as anu from tkinter import Tk, font nexWindow= anu.Tk() all_fonts= list(font.families()) for font_name in all_fonts: print(font_name)
We can create level just like
And I just need to pack. We can write mLabel.pack().
import tkinter as anu from tkinter import Tk, font nexWindow= anu.Tk() all_fonts= list(font.families()) for font_name in all_fonts: print(font_name) nexWindow.geometry("500x500") mLabel= anu.Label(nexWindow, text="I'm Shreejani", background="cyan", foreground="Black", font=("Arial Black",20,"bold"), relief="groove", borderwidth=10) mLabel.pack()
But if run this program, because in Tkinter l have to run it in a main loop. I have to write this netWindow.mainloop().
import tkinter as anu from tkinter import Tk, font nexWindow= anu.Tk() all_fonts= list(font.families()) for font_name in all_fonts: print(font_name) nexWindow.geometry("500x500") mLabel= anu.Label(nexWindow, text="I'm Shreejani", background="cyan", foreground="Black", font=("Arial Black",20,"bold"), relief="groove", borderwidth=10) mLabel.pack() nexWindow.mainloop()
So, if I run it, and see the output in my window.
Output: PS C:\Users\shree\OneDrive\Desktop\Internship_shreejani> & "C:/Program Files/Python312/python.exe" c:/Users/shree/OneDrive/Desktop/Internship_shreejani/listnew.py System 8514oem Fixedsys Terminal Modern Roman Script ROG Fonts Marlett Arial Arabic Transparent Arial Baltic Arial CE Arial CYR Arial Greek Arial TUR Arial Black Bahnschrift Light Bahnschrift SemiLight Bahnschrift Bahnschrift SemiBold Bahnschrift Light SemiCondensed Bahnschrift SemiLight SemiConde Bahnschrift SemiCondensed Bahnschrift SemiBold SemiConden Bahnschrift Light Condensed Bahnschrift SemiLight Condensed Bahnschrift Condensed Bahnschrift SemiBold Condensed Calibri Calibri Light Cambria Cambria Math Candara Candara Light Comic Sans MS Consolas Constantia Corbel Corbel Light Courier New Courier New Baltic Courier New CE Courier New CYR Courier New Greek Courier New TUR Ebrima Franklin Gothic Medium Gabriola Gadugi Georgia HoloLens MDL2 Assets Impact Ink Free Javanese Text Leelawadee UI Leelawadee UI Semilight Lucida Console Lucida Sans Unicode Malgun Gothic @Malgun Gothic Malgun Gothic Semilight @Malgun Gothic Semilight Microsoft Himalaya Microsoft JhengHei @Microsoft JhengHei Microsoft JhengHei UI @Microsoft JhengHei UI Microsoft JhengHei Light @Microsoft JhengHei Light Microsoft JhengHei UI Light @Microsoft JhengHei UI Light Microsoft New Tai Lue Microsoft PhagsPa Microsoft Sans Serif Microsoft Tai Le Microsoft YaHei @Microsoft YaHei Microsoft YaHei UI @Microsoft YaHei UI Microsoft YaHei Light @Microsoft YaHei Light Microsoft YaHei UI Light @Microsoft YaHei UI Light Microsoft Yi Baiti MingLiU-ExtB @MingLiU-ExtB PMingLiU-ExtB @PMingLiU-ExtB MingLiU_HKSCS-ExtB @MingLiU_HKSCS-ExtB Mongolian Baiti MS Gothic @MS Gothic MS UI Gothic @MS UI Gothic MS PGothic @MS PGothic MV Boli Myanmar Text Nirmala UI Nirmala UI Semilight Palatino Linotype Sans Serif Collection Segoe Fluent Icons Segoe MDL2 Assets Segoe Print Segoe Script Segoe UI Segoe UI Black Segoe UI Emoji Segoe UI Historic Segoe UI Light Segoe UI Semibold Segoe UI Semilight Segoe UI Symbol Segoe UI Variable Small Light Segoe UI Variable Small Semilig Segoe UI Variable Small Segoe UI Variable Small Semibol Segoe UI Variable Text Light Segoe UI Variable Text Semiligh Segoe UI Variable Text Segoe UI Variable Text Semibold Segoe UI Variable Display Light Segoe UI Variable Display Semil Segoe UI Variable Display Segoe UI Variable Display Semib SimSun @SimSun NSimSun @NSimSun SimSun-ExtB @SimSun-ExtB Sitka Small Sitka Small Semibold Sitka Text Sitka Text Semibold Sitka Subheading Sitka Subheading Semibold Sitka Heading Sitka Heading Semibold Sitka Display Sitka Display Semibold Sitka Banner Sitka Banner Semibold Sylfaen Symbol Tahoma Times New Roman Times New Roman Baltic Times New Roman CE Times New Roman CYR Times New Roman Greek Times New Roman TUR Trebuchet MS Verdana Webdings Wingdings Yu Gothic @Yu Gothic Yu Gothic UI @Yu Gothic UI Yu Gothic UI Semibold @Yu Gothic UI Semibold Yu Gothic Light @Yu Gothic Light Yu Gothic UI Light @Yu Gothic UI Light Yu Gothic Medium @Yu Gothic Medium Yu Gothic UI Semilight @Yu Gothic UI Semilight Agency FB Algerian Arial Narrow Arial Rounded MT Bold Baskerville Old Face Bauhaus 93 Bell MT Berlin Sans FB Berlin Sans FB Demi Bernard MT Condensed Blackadder ITC Bodoni MT Bodoni MT Black Bodoni MT Condensed Bodoni MT Poster Compressed Book Antiqua Bookman Old Style Bookshelf Symbol 7 Bradley Hand ITC Britannic Bold Broadway Brush Script MT Californian FB Calisto MT Castellar Centaur Century Century Gothic Century Schoolbook Chiller Colonna MT Cooper Black Copperplate Gothic Bold Copperplate Gothic Light Curlz MT Dubai Dubai Light Dubai Medium Edwardian Script ITC Elephant Engravers MT Eras Bold ITC Eras Demi ITC Eras Light ITC Eras Medium ITC Felix Titling Footlight MT Light Forte Franklin Gothic Book Franklin Gothic Demi Franklin Gothic Demi Cond Franklin Gothic Heavy Franklin Gothic Medium Cond Freestyle Script French Script MT FZShuTi @FZShuTi FZYaoTi @FZYaoTi Garamond Gigi Gill Sans MT Gill Sans MT Condensed Gill Sans MT Ext Condensed Bold Gill Sans Ultra Bold Gill Sans Ultra Bold Condensed Gloucester MT Extra Condensed Goudy Old Style Goudy Stout Haettenschweiler Harlow Solid Italic Harrington High Tower Text Imprint MT Shadow Informal Roman Jokerman Juice ITC Kristen ITC Kunstler Script LiSu @LiSu Lucida Bright Lucida Calligraphy Lucida Fax Lucida Handwriting Lucida Sans Lucida Sans Typewriter Magneto Maiandra GD Matura MT Script Capitals Mistral Modern No. 20 Monotype Corsiva MS Outlook MS Reference Sans Serif MS Reference Specialty MT Extra Niagara Engraved Niagara Solid OCR A Extended Old English Text MT Onyx Palace Script MT Papyrus Parchment Perpetua Perpetua Titling MT Playbill Poor Richard Pristina Rage Italic Ravie Rockwell Rockwell Condensed Rockwell Extra Bold Script MT Bold Showcard Gothic Snap ITC STCaiyun @STCaiyun Stencil STFangsong @STFangsong STHupo @STHupo STKaiti @STKaiti STLiti @STLiti STSong @STSong STXihei @STXihei STXingkai @STXingkai STXinwei @STXinwei STZhongsong @STZhongsong Tempus Sans ITC Tw Cen MT Tw Cen MT Condensed Tw Cen MT Condensed Extra Bold Viner Hand ITC Vivaldi Vladimir Script Wide Latin Wingdings 2 Wingdings 3 YouYuan @YouYuan Cascadia Code ExtraLight Cascadia Code Light Cascadia Code SemiLight Cascadia Code Cascadia Code SemiBold Cascadia Mono ExtraLight Cascadia Mono Light Cascadia Mono SemiLight Cascadia Mono Cascadia Mono SemiBold PS C:\Users\shree\OneDrive\Desktop\Internship_shreejani>