Benjamin,<br><br>Thanks for the reply.<br><br><br><div class="gmail_quote">On Tue, Aug 21, 2012 at 12:35 PM, Benjamin Berg <span dir="ltr"><<a href="mailto:benzea@sugarlabs.org" target="_blank">benzea@sugarlabs.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">On Tue, 2012-08-21 at 12:18 +0530, Ajay Garg wrote:<br>
> I am wanting to solve an issue, which in the present case seems<br>
> possible ONLY by using two threads.<br>
<br>
</div>Adding threads into the mix would not help you with your issue<br>
(threading support in GTK+ is currently being deprecated for good<br>
reasons, so then you can only do GTK+ calls from the main thread).<br>
<br>
In the normal case, when the GUI is updated a queue_draw() is done. The<br>
corresponding expose events are only fired when the main loop is<br>
executed, ie. when your function returns.<br>
<br>
I think what you are searching for right now is the the process_updates<br>
function of GdkWindow. This does exactly what you are requesting. </blockquote><div><br><br>A straightforward query here (sorry for my limited knowledge) ::<br><br>Does calling "process_updates" causes the GUI updates to take place, before the user returns from the function?<br>
That is, will the following scenario necessarily happen ::<br><br> logic statement 1<br> update GUI<br> process_updates ===> causes the GUI update<br> logic statement 2 ===> necessarily after GUI update<br>
<br><br><br>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.<br>Anyhow, just wish to confirm :)<br><br><br>Thanks and Regards,<br>
Ajay<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Please<br>
note that you don't have much control here, you don't know how fast the<br>
update will happen, or even if it is ever visible to the user. The X<br>
server will process the drawing commands when it sees fit.<br>
<div class="im"><br>
> My intention is to somehow have GUI updates in a synchronous manner,<br>
> and not rely upon "gobject.idle_add", which would have to have<br>
> dividing a long workflow into many sub-parts, and chaining these<br>
> sub-parts through "gobject.idle_add".<br>
> This is EXTREMELY painful, especially when one needs to do it on an<br>
> already existing codebase.<br>
<br>
</div>As an alternative you could do something like:<br>
<br>
def idle_add_function(pos):<br>
if pos[0] == 1:<br>
# logic 1<br>
elif pos[0] == 2:<br>
# logic 2<br>
else:<br>
return False<br>
<br>
queue_update()<br>
<br>
pos[0] += 1<br>
return True<br>
<br>
Where pos = [0] to begin with (the usage of the list is just so that it<br>
is global in a way, any object will do, it just needs to be something<br>
permuteable).<br>
<span class="HOEnZb"><font color="#888888"><br>
Benjamin<br>
<br>
</font></span></blockquote></div><br>