[pygtk] Downloading a file without locking the GUI
Steve McClure
smcclure at racemi.com
Thu Oct 2 02:54:24 WST 2008
On Oct 1, 2008, at 2:16 PM, Timo wrote:
> Thomas Guettler schreef:
>> Timo schrieb:
>>> I want to download a file by pressing a button in my GUI, all works
>>> so that's okay. Offcourse my GUI locks up during the download.
>>> I tried some things like writing a thread and using
>>> gobject.idle_add.
>>> But none of these worked.
>>> Anyone can point me out to some kind of example or tutorial?
>>>
>>>
>> Hi,
>>
>> You could use PixbufLoader, non-blocking IO and idle_add. This
>> solution works without
>> threads. I try to avoid them.
>>
>> Sorry, that's not an example or tutorial, but if you found idle_add,
>> you will get this done, too.
>>
>> HTH,
>> Thomas
>>
> I don't get the pixbufloader thing, since I don't download images. But
> maybe I'm just missing something.
>
> Well, after searching and trying again, still no progress. I guess I'm
> just missing something.
>
> Here's what I want to do, maybe someone has an idea how to do this:
>
> def buttonclicked(widget):
> urllib.urlretrieve(url, downloadpath)
>
> I was also thinking about adding a progressbar during download, but
> if I
> can't even get this done...
If you just wanted progress you could use a reporthook function passed
to urlretrieve that would update the UI then
while gtk.events_pending():
gtk.mainiteration(False)
to update the UI. That should make your UI responsive to the user to
and you just have to be careful that you don't call mainiteration, or
mainloop, from multiple places. Keep in mind that my application is
so old that I use 1.x so the programming model, or just names, might
have changed in 2.x.
>
>
> Thanks,
> Timo
>
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
--
Steve McClure
smcclure at racemi.com
More information about the pygtk
mailing list