[Sugar-devel] Is there a way to purposefully do synchronous GUI updates?

Benjamin Berg benzea at sugarlabs.org
Tue Aug 21 03:30:22 EDT 2012


On Tue, 2012-08-21 at 12:43 +0530, Ajay Garg wrote:
> Does calling "process_updates" causes the GUI updates to take place,
> before the user returns from the function?

Yes, the updates are done immediately and the drawing commands are
pushed out to the X server. And I do expect that this is *exactly* what
you requested.
You don't know exactly when the GUI update will be visible on the
screen. But that is normal and has nothing to do with process_updates.

An example where this mechanism was used in GTK+ is scrollbars. When you
are dragging them, they should be redrawn right away so that they move
correctly.

Benjamin

> That is, will the following scenario necessarily happen ::
> 
>                        logic statement 1
>                        update GUI
>                        process_updates  ===> causes the GUI update
>                        logic statement 2  ===> necessarily after GUI
> update
> 
> 
> 
> I doubt that the above is a guarantee, as you have already mentioned
> that the actual GUI processing will take place  whenever X server sees
> it fit.
> Anyhow, just wish to confirm :)
> 
> 
> Thanks and Regards,
> Ajay
>  
>         Please
>         note that you don't have much control here, you don't know how
>         fast the
>         update will happen, or even if it is ever visible to the user.
>         The X
>         server will process the drawing commands when it sees fit.
>         
>         > My intention is to somehow have GUI updates in a synchronous
>         manner,
>         > and not rely upon "gobject.idle_add", which would have to
>         have
>         > dividing a long workflow into many sub-parts, and chaining
>         these
>         > sub-parts through "gobject.idle_add".
>         > This is EXTREMELY painful, especially when one needs to do
>         it on an
>         > already existing codebase.
>         
>         
>         As an alternative you could do something like:
>         
>         def idle_add_function(pos):
>             if pos[0] == 1:
>                 # logic 1
>             elif pos[0] == 2:
>                 # logic 2
>             else:
>                 return False
>         
>             queue_update()
>         
>             pos[0] += 1
>             return True
>         
>         Where pos = [0] to begin with (the usage of the list is just
>         so that it
>         is global in a way, any object will do, it just needs to be
>         something
>         permuteable).
>         
>         Benjamin
>         
> 
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel




More information about the Sugar-devel mailing list