← Go Back
See also our tutorial on textboxes: Textbox (Entry) in Tk (tkinter).
How to Justify Text on Textbox in Tk (tkinter)
When creating an instance of thettk.Entry
class, use the justify
parameter:import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.geometry("400x300")
# Possible alignments:
# - tk.LEFT (default value)
# - tk.RIGHT
# - tk.CENTER
entry = ttk.Entry(justify=tk.CENTER)
entry.pack()
root.mainloop()
See also our tutorial on textboxes: Textbox (Entry) in Tk (tkinter).
🐍 You might also find interesting: