I have a tree which I populate with a file list from my computer on the click of a button. While the program is populating the tree the whole GUI hangs.
Is there a way to populate the tree in another thread so the tree gets populated as the files are found and not when everything has already been added? Or any other ideas?
This is what it looks like:
I am populating the tree with this code:
def traversePaths(self, path, parent):
files = os.listdir(path)
files.sort()
for myfile in files:
if myfile[0] != ".":
if os.path.isdir(path + os.sep + myfile):
current = self.filelist.append(parent,[self.dirIcon,self.dirIcon,self.dirOpenIcon,myfile,"DD",True,True,3])
self.traversePaths(path + os.sep + myfile, current)
else:
current = self.filelist.append(parent,[self.fileIcon,self.dirIcon,self.dirOpenIcon,myfile,"AA",True,True,3])
which is executed on a button click:
def on_refreshbutton_clicked(self, button):
self.traversePaths(self.path.get_filename(), None)
I don't think threading.Thread works because of the gtk thread for the gui and cannot find gi.repository.Gtk api's on the subject
Any ideas?