- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements