Tkinter Label – Bold Text

Tkinter Label bold text

To set bold weighted font style for a Label widget in Tkinter, create a Font object with the weight parameter of Font() constructor set to “bold”, and pass this font object as argument to the font parameter of Label() constructor.

Tkinter Label bold
Tkinter Label widget with bold text and normal text comparison

In this tutorial, you will learn how to set the bold font style for a Label widget, with examples.

Steps to set bold text for Label in Tkinter

Step 1

Import font from tkinter library, and create a Font class object with weight parameter set to bold.

from tkinter import font
label_font = font.Font(weight="bold")

Step 2

Create a label widget using tkinter.Label class constructor and pass the label_font (created in the above step) as argument to the font parameter.

tk.Label(window, text="Hello World!", font=label_font)

Examples

1. Label with bold text

In this example, we shall create a Label with text Hello World! and font weight to bold, and display it in the main window.

Program

import tkinter as tk
from tkinter import font

# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")
window.geometry("300x200")

# Create font object
label_font = font.Font(weight="bold")

# Create a label widget with specific font
label = tk.Label(window, text="Hello World!", font=label_font)

# Pack the label widget to display it
label.pack()

# Run the application
window.mainloop()

Output

Run on a MacOS.

Tkinter Label bold text - Example
Tkinter Label widget with bold text

Summary

In this Python Tkinter tutorial, we learned how to create a Label widget with italic text, with examples.

Code copied to clipboard successfully 👍