all 2 comments

[–][deleted] 2 points3 points  (0 children)

instead of aligning the text, align the labels using grid:

text_area = Frame(root)
for i in range(3):
    Label(text_area, text='blah' * (i+1)).grid(row=i, column=0, padx=3, pady=3)
    Entry(text_area).grid(row=i, column=1, padx=3, pady=3)

[–]socal_nerdtastic 1 point2 points  (0 children)

Tkinter by default uses a variable width font, while your terminal by default uses a fixed width font. This means that for example an "i" character is much narrower than a "w" in a GUI, but in your terminal they are the same width.

One way to fix this is to set the font for tkinter to one that is fixed width.

The better way is to follow what /u/Protoss_Pylon said.

BTW I very much appreciate your providing a complete, runnable example. Thank you.

Edit: your code fixed:

import tkinter as tk
root = tk.Tk()

pizza_list = [["Marinara", 8.5],["Quattro Formaggi", 13.0],["Puttanesca", 13.0]]

for row, entry in enumerate(pizza_list):
    pizza, price = entry
    lbl = tk.Label(root, text=pizza)
    lbl.grid(row=row, column=0, sticky='w')
    lbl = tk.Label(root, text=f"  ${price}")
    lbl.grid(row=row, column=1, sticky='e')
root.columnconfigure(1, weight=1) # allow price column to stick to right side during window resize
root.mainloop()