问题
Found a solution. See below.
I am using GTK 3.8 gtk_grid in a scrolled window. The C code works through a lot of data and displays some in the grid. GTK does not draw the grid until the program finishes processing all data. How do you force GTK 3 to refresh the screen when you add data?
I tried gtk_widget_queue_draw but nothing happens. I also tested gtk_widget_show_now but nothing happened.
The process might run for a few seconds or many minutes. The user can select the range of data to display and the refresh. The refresh might be every 5 seconds or every 10 rows. I would be happy if either worked.
The only relevant question I can find is on GTK 2 and recommends gtk_widget_queue_draw which does not work. I read all the GTK documentation and that recommends the same function. Something is missing in the documentation, examples, and answers.
From what I can see, I would have to process 100 rows then stop and display a button to request the next 100. This is not viable. The user needs the data scrolling through to the end.
GTK_grid appears to have changed a few times in version 3. I am not locked into GTK_grid if there is a more efficient or effective way to display rows and columns. There is no option to revert to an earlier GTK.
I found something that works in GTK 3.8. Add a line after gtk_widget_queue_draw:
gtk_widget_queue_draw(results);
while (g_main_context_pending(NULL)) {
g_main_context_iteration(NULL,FALSE);
}
Read The Main Event Loop for more details.
来源:https://stackoverflow.com/questions/34912757/how-do-you-force-a-screen-refresh-in-gtk-3-8