⊕
⊖
Contents
Tkinter Entry – Right align text
In Tkinter, you can right align the text entered in the Entry widget, using justify parameter, as shown in the following screenshot.
To right align the text in an Entry widget in Tkinter, set the justify parameter to “right” when creating Entry using tk.Entry().
For example, the following code creates an Entry widget with right aligned text.
tk.Entry(window, justify="right")
In this tutorial, you will learn how to right align the text in an Entry widget, with examples.
Examples
1. Right align text in Entry widget
In this example, we create a basic Tk window with an Entry widget. We right 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 right
entry = tk.Entry(window, justify="right")
entry.pack()
# Run the application
window.mainloop()
Output
Output in Windows
Output in MacOS
Summary
In this Python Tkinter tutorial, we have seen how to right align the text in an Entry widget in Tkinter, with examples.