What's the point of doing the Gtk::Main::iteration()
on the last two lines of the answer to this question? I'm using pygtk, so the equivalent question would be, why do gtk.main_iteration_do()
? Isn't the main loop that's running already taking care of this?
views:
26answers:
2These functions exist to let you create your own loop, and have an iteration of GTK's loop run somewhere in it.
You may want to take care of other stuff while the loop runs, in the same thread/process as the loop. Many libraries with main loops provide either a way to schedule tasks in their main loop, or a function to run a single iteration of the loop for you embed somewhere else.
When I wrote that answer, I was assuming that the items would be added in a long loop - for example in a callback somewhere. Unless you're explicitly doing the work in a separate thread, then the main loop is in fact not running during that code. The code there tells the window to scroll to the bottom, but the scrolling only actually happens when the main loop regains control.
"While events pending, do main interation" in whatever language is an often-used way to run the main loop until all waiting GUI updates have been processed.