[pygtk] PyGTK Thread problem

Thomas Güttler hv at tbz-pariv.de
Fri Apr 13 14:51:10 WST 2007


Am Donnerstag, 12. April 2007 18:32 schrieb Rodrigo Uroz:
> Regarding this, another problem. Now I get my thread to update the GUI
> through a callback in my main thread, but the TextView gets updated only
> the first time, then the callback gets called again and again but doesn't
> automatically update the GUI (I have to click in the TextView to update
> it).
>
> What could be going wrong?, I couldn't find a solution looking in the mail
> list.
>

Is your main thread busy? Updates only happen after the main thread
returns from the callback.

BTW: I switched from threads to idle_add. It is much easier to debug.

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq03.007.htp

"""
3.7. While my callback is executing, nothing is refreshed in the application 
windows!
If you have a long-running callback, or one that modifies the application 
windows during its execution, you will notice that the windows of your app 
freeze for the duration of the callback. This is by design: all gtk events 
(including window refreshing and updates) are handled in the mainloop, and 
while it has branched to process your callback, it can't handle window update 
events.Therefore nothing will happen in the application windows.

The trick here is to realize where your callback can take a while to return, 
or where it is dynamically changing the window contents, and add a section 
like this in the body of your callback handler:

 while gtk.events_pending():
   gtk.main_iteration(False
"""

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917


More information about the pygtk mailing list