I try to implement a file manager, the question arises as using Treeview to display a directory for specified so that would have happened in TotalCommander'e
Here's a snippet of code:
from tkinter import *
from tkinter import ttk
class FileBrowser(Frame):
def __init__(self, root):
Frame.__init__(self, root)
self.master.title('Файловый менеджер')
self.master.geometry('1024x768')
listframe = Frame(root, bd=5)
listframe.pack(side='top', fill=BOTH, expand=1)
self.filedirlist = ttk.Treeview(listframe)
self.filedirlist["columns"]=("#1", "#2", "#3", "#4")
self.filedirlist.column("#0", width=175, minwidth=100)
self.filedirlist.column("#1", width=100, minwidth=100)
self.filedirlist.column("#2", width=100, minwidth=100)
self.filedirlist.column("#3", width=100, minwidth=100)
self.filedirlist.column("#4", width=100, minwidth=100)
self.filedirlist.heading("#0", text="Имя")
self.filedirlist.heading("#1", text="Режим")
self.filedirlist.heading("#2", text="Частота, МГц")
self.filedirlist.heading("#3", text="Размер, Мб")
self.filedirlist.heading("#4", text="Комментарий")
self.filedirlist.pack(side='top', fill=BOTH, expand=1)
listsb = Scrollbar(self.filedirlist,
orient=HORIZONTAL, command=self.filedirlist.xview)
listsb.pack(side=BOTTOM, fill=X)
self.listbuttonopen = Button(listframe,
text='Open').pack(side='left', padx='10', pady='5')
self.listbuttondelete = Button(listframe,
text='Delete').pack(side='left', padx='10', pady='5')
self.listbuttonload = Button(listframe,
text='Load').pack(side='left', padx='10', pady='5')
if __name__=='__main__':
root = Tk()
FileBrowser(root).pack()
root.mainloop()
When displaying folders should be active only the columns "Имя" and "Комментарий" and the remaining columns are active only when the contents of the selected folder.
Actually the question: Is it possible to implement it using Treeview'ra and how?)
P.S. Sorry for my English)