How to set the height/width of a Label widget in Tkinter?


The Label widgets are used for displaying text and images in the 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 height and 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="How to set the height/width " "of a Label widget in Tkinter?", font=('Times 14'), width=60, height=15)
label.pack()

win.mainloop()

Output

Running the above code will display a window that contains a label widget within width and height.

Updated on: 19-Jun-2021

15K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements