Re: [gtk-win32] Updating a progress bar from a worker thread



Il giorno sab, 19/12/2009 alle 13.05 +0000, John Emmas ha scritto:
> ----- Original Message ----- 
> From: "John Emmas"
> >
> > the GUI elements seem to be getting created and initialized successfully.
> > It's only the updates that don't seem to be working properly....  :-(
> >
> I found the answer in a textbook!!  After updating the progress bar I needed
> to add these two lines to my loop:-
> 
>       while (gtk_events_pending())
>             gtk_main_iteration();
> 
> However -  because I'm using a signal to initiate the updates, I could
> either put those lines in my worker thread - or alternatively, in the signal
> handler (which is in the main GUI thread).  Please can someone tell me
> if either of those places is preferable to the other?

I'm pretty certain that most gtk programmers would just use timeout_add
or timeout_add_seconds from glib to do what you're trying to do with
threads. I think it's right to say that thread are rarely needed in gtk
application, and threads that play with the interface can almost always
be avoided, with good consequences for what concerns ease of coding.



I don't program under Windows (yes, it's just that I forgot to
unsubscribe from this list...), but if I understood correctly the
substitute of InvalidateRect() you're searching for is
gtk.Widget.queue_draw_area. Notice however that you usually should not
need to call this, unless you're creating a new custom widget.

Pietro



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