How to justify text in label in tkinter in Python Need justify in tkinter?

PythonTkinterServer Side ProgrammingProgramming

Tkinter Label widgets are used to add images and create text in a particular application. There are various functions and methods available in the library which can be used to style the widgets and its property. In order to justify the text in the label widget, we can use the justify property. It is generally used to justify the position or the alignment of the text such as RIGHT, LEFT, and CENTER.


In this application, we will justify the position of a text label using the justify property.

#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
#Crate a Label widget
label1= Label(win, text="Box1")
label2= Label(win, text= "\nKeep\nLearning", bd=1, relief= "solid",font= ("Helvetica 20"), justify= RIGHT)
Label(win, text= "Box2").pack()
label3= Label(win, text="\nLearning\nMakes\nPerfect", bd=1, relief="solid", font=('Helvetica 20'), justify= LEFT)


Running the above code will display a window that contains a label widget with some text. The visual alignment of the text can be defined by the justify property.

Published on 22-Apr-2021 10:43:28