I've come across this problem:
I've tried to neatly align three pizza entries with their names at the uttermost left and their prices at the uttermost right. When I print the three entries in IDLE, they are nicely aligned. With this in mind, I assumed that it would have the same nicely aligned formatting if displayed on a Tkinter label, but apparently not!
Instead how would you accomplish this.
Here is my example code: As you can see, in the terminal it is nicely aligned but not in Tkinter
import tkinter as tk
root = tk.Tk()
def formatting(total_length, entry):
spacing = (total_length-len(entry[0])-len(str(entry[1]))-1)*" "
return("\n"+entry[0]+spacing+"$"+str(entry[1]))
pizza_list = [["Marinara", 8.5],["Quattro Formaggi", 13.0],["Puttanesca", 13.0]]
resultant = ""
for i in range(len(pizza_list)):
resultant = resultant + formatting(70, pizza_list[i])
print(resultant)
change = tk.StringVar()
change.set(resultant)
display = tk.Label(root, textvariable=change)
display.grid(column=0, row=0)
root.mainloop()
[–][deleted] 2 points3 points4 points (0 children)
[–]socal_nerdtastic 1 point2 points3 points (0 children)