How to list directory hierarchy in PyGTK treeview widget?
- by lyrae
I am trying to generate a hierarchical directory listing in pyGTK.
Currently, I have this following directory tree:
/root
folderA
- subdirA
- subA.py
- a.py
folderB
- b.py
I have written a function that -almost- seem to work:
def go(root, piter = None):
for filename in os.listdir(root):
isdir = os.path.isdir(os.path.join(root, filename))
piter = self.treestore.append(piter, [filename])
if isdir == True:
go(os.path.join(root, filename), piter)
This is what i get when i run the app:
I also think my function is inefficient and that i should be using os.walk(), since it already exists for such purpose.
How can I, and what is the proper/most efficient way of generating a directory tree with pyGTK?