Python Forum
Setting Tabs in a listbox - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Setting Tabs in a listbox (/thread-22437.html)



Setting Tabs in a listbox - scratchmyhead - Nov-12-2019

I'm using Python 3.8 and using Tkinter. I'm trying to set tabs inside of a listbox. I have the following code:

for record in records:
    txt =str(record[0]) + '\t' + '\t' + '\t' + str(record[1])
    lb.insert("end", txt )
But it doesn't do tabs. Both records are up against each other when displayed in the listbox. Any help would be appreciated.


RE: Setting Tabs in a listbox - Larz60+ - Nov-12-2019

try: (python 3.6 or newer)
lb.insert("end", f"{record[0]}\t\t\t{record[1]}")



RE: Setting Tabs in a listbox - scratchmyhead - Nov-12-2019

That worked. Thank you.