Re: Best way to busy-wait in Python 3 / Gtk+ 3?



Thanks, your method works. However, it still takes the program quite a bit
to load up, and my problem is that I want display the window as soon as
possible. If that helps, here is how the program loads up:
Script starts
The window is constructed
Window events are connected to their handlers
window.show_all()
When the window is ready, TED Talks are loaded and processed.
Then, widgets for the talks are created. In the widget's constructor, I
call GdkPixbuf.Pixbuf.new_from_stream_async.

Problem: The window does not show up when loading the images (something
that I hoped _async would make possible).

On 8 October 2012 08:32, Simon Feltman <s feltman gmail com> wrote:

On Sun, Oct 7, 2012 at 9:10 PM, Michael Torrie <torriem gmail com> wrote:
Maybe the best way is to avoid processes or threads altogether.  Since
downloading this thumbnail is io-bound, not cpu-bound, once you send off
your request, just use io watches to trigger the main loop when
something has come in.

Agreed, better yet, the code could become much simpler using an async
pixbuf:

def on_image_ready(stream, res, user_data):
    pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(res)
    ...
file = Gio.File.new_for_uri("...")
GdkPixbuf.Pixbuf.new_from_stream_async(file.read(None), None,
on_image_ready, None)

All within a main loop of course.

-Simon
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
_____________________
Filip Lamparski - FB <https://www.facebook.com/filip.lamparski> -
G+<https://plus.google.com/105688569486178456264/posts>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]