Dann lohnt sich dieser Formatstring hier gar nicht. Hab ich es eben so gemacht:
Code: Alles auswählen
import tkinter as tk
root = tk.Tk()
DIR_TYPE = 0
DEVICE_ROOT = (("Documents",DIR_TYPE),("Music",DIR_TYPE),("Pictures",DIR_TYPE),("Videos",DIR_TYPE))
list_box = tk.Listbox(root,font='TkFixedFont',selectmode='extended')
list_box.pack(side='right')
def fill_line(widget,par,info,info_len):
par_width = widget['width'] - 1 - info_len
return (par + " "*(par_width - len(par)))[0:par_width] + "|" + info
def fill_dir(dir_list=DEVICE_ROOT,lb=list_box,first="/"):
lb.delete(0,'end')
lb.insert('end',fill_line(lb,first,first,3))
for entry in dir_list:
lb.insert('end',fill_line(lb,entry[0],'DIR' if entry[1] == DIR_TYPE else '',3))
fill_dir()
root.mainloop()