Python Forum

Full Version: How to format a list when displaying in a tkinter Listbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a list that has 3 columns. How can I insert a tab to space out the columns while displaying the rows in a tkinter listbox.
I insert the the with:

for item in myList:
    listbox.insert(END, item)

I've done a little digging and can space them out using .format(), how can I change this code to use tabs instead?

for row in range(len(myList)):
    item = "{:<25s}{:>6s}".format(myList[row][0],myList[row][1])
    print(item)
    listbox.insert(END, item)
The tab character is \t.
(Apr-02-2018, 05:19 PM)nilamo Wrote: [ -> ]The tab character is \t.
Yes but that doesn't appear to be valid systax to use with .format()
You want to use tkinter.ttk treeview, here's an example: https://pyinmyeye.blogspot.com/2012/07/t...-demo.html