Here's how I created a tree file viewer. I could have made a function to save all of the repetition, but I feel like there was an easier way I just didn't see it.
root = dirc.AddRoot('Gene Library')
#PHYLUM
phylumpath = glob.glob("/Users/austinportal/Documents/GBA/*")
phylum_name = os.listdir("/Users/austinportal/Documents/GBA/")
phylumname = []
trash963 = []
for path in phylum_name:
if path[0] is ".":
trash963.append(".")
else:
phylumname.append(path)
phylum_item = []
a=0
for phylum in phylumname:
if phylum[0] is ".":
trash963.append(".")
else:
phylum_item.append(dirc.AppendItem(root, phylum))
dirc.SetPyData(phylum_item[a], phylumpath[a])
a +=1
genus_item = []
#GENUS
master_genus_path = []
lc=0
while lc < len(phylum_item):
path = glob.glob("%s/*" % phylumpath[lc])
for p in path:
master_genus_path.append(p)
lc+=1
lc=0
while lc < len(phylum_item):
genuspath = glob.glob("%s/*" % phylumpath[lc])
genusname = os.listdir("%s/" % phylumpath[lc])
a=0
for genus in genusname:
if genus[0] is ".":
trash963.append(".")
else:
genus_item.append(dirc.AppendItem(phylum_item[lc], genus))
dirc.SetPyData(genus_item[-1], genuspath[a])
a +=1
lc+=1
filedir = {}
#SPECIES
spec_item = []
master_species_path = []
lc=0
while lc < len(genus_item):
specpath = glob.glob("%s/*" % master_genus_path[lc])
specname = os.listdir("%s/" % master_genus_path[lc])
a=0
for spec in specname:
if spec[0] is ".":
trash963.append(".")
else:
spec_item.append(dirc.AppendItem(genus_item[lc], spec))
dirc.SetPyData(spec_item[-1], specpath[a])
a +=1
lc+=1
for path in specpath:
master_species_path.append(path)
#STRAIN
print master_species_path
strain_item = []
lc=0
while lc < len(spec_item):
strainpath = glob.glob("%s/*" % master_species_path[lc])
strainname = os.listdir("%s/" % master_species_path[lc])
a=0
for strain in strainname:
if strain[0] is ".":
trash963.append(".")
else:
strain_item.append(dirc.AppendItem(spec_item[lc], strain))
dirc.SetPyData(strain_item[-1], strainpath[a])
a +=1
lc+=1