
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add Label Width in Tkinter
A Label widget is used to display text and images in an application. The size of the label widget depends on a number of factors such as width, height, and Font-size of the Label text. The height and width define how the label widget should appear in the window.
To set the width of the label widget, we should declare the Label widget with a variable. Instantiating the label widget with a variable allows the users to add/edit the properties of the Label widget.
Example
# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add a Label widget label=Label(win, text="A Label widget is used to display text " "and images in an application.", font=('Times 14'), width=100) label.pack() win.mainloop()
Output
If you run the above code, it will display a window that contains a Label text with some width.
Advertisements