How to display multiple lines of text in Tkinter Label?

Tkinter Label widgets are created by defining the Label(parent, **options) constructor in the program. We use the Label widget to display text or images in any application. If we want to display text, we have to assign a value to the text attribute in the constructor. You can also add multiple lines of text in the label widget by using \n newline character. It will separate the current text to the next line in the Label widget.

Basic Multi-line Text Example

Here's how to create a label with multiple lines using the newline character (\n) ?

# Import the tkinter library
from tkinter import *

# Create an instance of tkinter frame
win = Tk()

# Set the size of the Tkinter window
win.geometry("700x350")

# Add a label widget with multiple lines
label = Label(win, text="Hello There!\nHow are you?", font=('Arial', 17))
label.pack()

win.mainloop()

Using justify Parameter for Text Alignment

You can control how multi-line text is aligned using the justify parameter ?

from tkinter import *

win = Tk()
win.geometry("400x300")
win.title("Multi-line Label Alignment")

# Left justified text (default)
label1 = Label(win, text="Line 1\nThis is line 2\nShort line", 
               font=('Arial', 12), justify='left', bg='lightblue')
label1.pack(pady=10)

# Center justified text
label2 = Label(win, text="Line 1\nThis is line 2\nShort line", 
               font=('Arial', 12), justify='center', bg='lightgreen')
label2.pack(pady=10)

# Right justified text
label3 = Label(win, text="Line 1\nThis is line 2\nShort line", 
               font=('Arial', 12), justify='right', bg='lightcoral')
label3.pack(pady=10)

win.mainloop()

Using wraplength for Automatic Line Wrapping

The wraplength parameter automatically wraps long text to fit within a specified width ?

from tkinter import *

win = Tk()
win.geometry("500x300")
win.title("Text Wrapping Example")

long_text = "This is a very long text that will be automatically wrapped to multiple lines based on the wraplength parameter setting."

# Without wraplength
label1 = Label(win, text=long_text, font=('Arial', 12), bg='lightyellow')
label1.pack(pady=10, padx=20)

# With wraplength set to 300 pixels
label2 = Label(win, text=long_text, font=('Arial', 12), 
               wraplength=300, bg='lightblue', justify='center')
label2.pack(pady=10, padx=20)

win.mainloop()

Comparison of Methods

Method Use Case Control
\n character Manual line breaks Full control over line breaks
wraplength Automatic wrapping Automatic based on width
justify Text alignment Left, center, or right alignment

Conclusion

Use \n for manual line breaks in Tkinter labels. Combine with justify for text alignment and wraplength for automatic text wrapping to create professional-looking multi-line labels.

Updated on: 2026-03-25T22:21:11+05:30

18K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements