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 a 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 next line attribute. It will separate the current text to the next line in the Label widget.

Example

# 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
label= Label(win, text= "Hello There!\n How are you?", font= ('Aerial', 17))
label.pack()

win.mainloop()

Output

Executing the above code will display a multiline Label Widget.

Updated on: 07-Jun-2021

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements