How to 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.

Updated on: 19-Jun-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements