[pygtk] events_pending & main_iteration_do

Thomas Perl th.perl at gmail.com
Sat Apr 25 05:11:38 WST 2009


You wrote:
> Hi, I have a widget that needs to use gtk.idle_add(...), in some situations
> I'd like to force gtk to process what is in idle. I thought I could use:
>
>  t = MyWidgetWidthIdle()
>  gtk.main_iteration_do()
>  t.my_method()
>
> But it does not seem to change anything, t.my_method() is called when the
> idle_callback has not yet been run.
>
> Do I understand exactly that main_iteration_do() is for this purpouse?
> Is there some other way to achieve the same geal?

There might be more than one task to do in the main iteration, so you
might run the main iteration as long as there is something to process:

while gtk.events_pending():
    gtk.main_iteration_do()

This will process all outstanding events.

HTH
thp


More information about the pygtk mailing list