Tkinter Entry - Left align text


Tkinter Entry - Left align text

In Tkinter, you can left align the text entered in the Entry widget, using justify parameter, as shown in the following screenshot.

Tkinter Entry - Left align text
Tkinter Entry - Text is left aligned

To left align the text in an Entry widget in Tkinter, set the justify parameter to "left" when creating Entry using tk.Entry().

For example, the following code creates an Entry widget with left aligned text.

tk.Entry(window, justify="left")

In this tutorial, you will learn how to left align the text in an Entry widget, with examples.

Examples

1. Left align text in Entry widget

In this example, we create a basic Tk window with an Entry widget. We left align the text in this Entry widget.

Python Program

import tkinter as tk

# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")
window.geometry("300x200")

label = tk.Label(window, text="Enter your input")
label.pack()

# Create an Entry widget with text aligned left
entry = tk.Entry(window, justify="left")
entry.pack()

# Run the application
window.mainloop()

Output

Output in Windows

Output in MacOS

Tkinter Entry - Left align text - Example
Tkinter Entry - Text left aligned

Summary

In this Python Tkinter tutorial, we have seen how to left align the text in an Entry widget in Tkinter, with examples.