I am a "novice" python user.
I have a listbox using tkinter and I want to format the list entries so they are aligned, and I have the following:
from Tkinter import *
master = Tk()
info=[ ['sue', 1, 'Argentina', 'Bsc'],
['peggy-sue', 17, 'U.K.', 'Bsc'],
['susie', 234, 'France', 'BA']
]
listbox = Listbox(master, width=60)
listbox.pack()
listbox.insert(END, "{:<15s} {:>5s} {:<25s} {:<5s}".format("Name","id","Nationality","Qual") )
for i in range(len(info)):
item = "{:<15s} {:>5d} {:<25s} {:<5s}".format(info[i][0],info[i][1],info[i][2],info[i][3])
print item # Gives nicely formatted lines
listbox.insert(END, item) #Lines are not nicely formatted in listbox
mainloop()
Can anyone explain why the listbox entries are not nicely formatted as the print line is?
I know about multi-column listboxes (e.g. Display Listbox with columns using Tkinter?) and so I don't need a solution, I am interested in why things aren't working as I had expected.
Thanks
