[pygtk] Updating a progressbar inside a recursive function
Felix Rabe (public)
public at felixrabe.textdriven.com
Tue Sep 26 03:58:33 WST 2006
Hi Adolfo,
You might not need to use recursive code, and generators aren't too bad. Have you looked at os.walk() already?
I have PyGTK example code that uses it. I have to package it up though, but I'll do that on (your) request. Feel free to answer in Spanish if that's your mother tongue.
Greetings,
Felix
Adolfo González Blázquez wrote:
> Hello,
>
> I'm writing a little app to mass rename files. The gui has two parts, on
> left a tree-like file browser for selecting the dir you want files to
> rename. On right, theres a treeview that shows the files that are inside
> the selected directory.
>
> What i want to do is update a progressbar while populating the treeview
> with the files.
>
> The problem comes when the "add files recursively" option is enabled.
> The app calls a recursive method to add everyfile inside that dir and
> its subdirs. This function uses to take a while to end, so the gui
> freezes till everyfile is read.
>
> I've tried using the tips on
> http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.020.htp
> but they don't work for me:
> - The while gtk.events_pending(): gtk.main_iteration() stuff seems to
> work, but when reading a dir, and changing to another, it should stop
> reading the first dir, clean the treeview, and read the new. But it
> reads the new, and still keeps adding files from the old dir.
> - I did not suceed trying the generator stuff, 'cause i dont know how to
> apply the example to a recursive function.
>
> I've tried threads also, but totally unsuccesful (new to threads...)
>
>
> So if anyone can point me anyway to solve this, or a good example, i
> will really appreciate it.
>
>
> The two functions related to this problem are pasted below:
> The complete .py file can be found here:
> http://www.infinicode.org/code/renamer.py
>
> Thank you very much in advance!
>
> -- adolfo
>
> -----------------------------------------------------------------------
> def dir_selected(self, obj, dir):
...
More information about the pygtk
mailing list