In this video I’ll show you how to define custom fonts for your tkinter app.

Setting custom fonts is incredibly useful because you can update all the fonts for all the widgets in your app with one quick change.

All we have to do is import Font from tkinter.font and we can define custom fonts to use in all the widgets of our app.

Python Code: fonts.py
(Github Code)

from tkinter import *
from tkinter.font import Font

root = Tk()
root.title('Codemy.com - Custom Fonts')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x500")

# Define Our Font
bigFont = Font(
	family="Times",
	size=40,
	weight="bold",
	slant="roman",
	underline=0,
	overstrike=0)

# Define Our Font
mediumFont = Font(
	family="Helvetica",
	size=24,
	weight="normal",
	slant="italic",
	underline=1,
	overstrike=0)

# Define A Button
my_button1 = Button(root, text="Big Text", font=bigFont)
my_button1.pack(pady=20)


# Label
my_label = Label(root, text="more big text", font=mediumFont)
my_label.pack(pady=20)

root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

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

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...