Tkinter Label – Left align text
You can left align the text in a Label widget in Tkinter as shown in the following screenshot.
To left align the text in a Label widget in Tkinter, set the anchor parameter to “w” (west) and the justify parameter to “left”.
The syntax to specify the anchor and justify parameters in a Label widget constructor, so that the text is left aligned, is as shown in the following.
In this tutorial, you will learn how to left align the text in a Label widget in Tkinter, with examples.
1. Left align text in a Label widget
In this example, we shall create a Label widget with some text, and set the alignment of the text to left.
We have set the background color and width, so that we can visually check if the text is actually left aligned or not.
import tkinter as tk # Create the main window window = tk.Tk() window.title("PythonExamples.org") window.geometry("300x200") # Create a label widget label = tk.Label( window, text="Hello World!", anchor="w", justify="left", width=25, bg="lightgreen" ) # Pack the label widget to display it label.pack() # Run the application window.mainloop()
Run on a MacOS.
In this Python Tkinter tutorial, we learned how to left align text in a Label widget, with examples.