[GTK+] Problem with images loaded in sequence
Hello everyone,
I have a problem with a GTK+ program that I am writing. I thought to put a progress bar that so many seconds increases a little. So I used ten images .png (progress1.png, progress2.png, etc.) indicating the status of progress. The problem is that if I create a window with the first image, if I put a function that blocks the implementation of the program of 5 seconds, the program draws the window after 5 seconds. I do not know if I make myself clear.
Example:
in the window appears progress1.png
XX
after 5 seconds becomes so (progress2.png)
XXXX
after another 5 seconds (progress3.png)
XXXXXX
and so forth. For each step, the image with the progress bar is overwritten by another. At least should do so, instead draws only the last, progress10.png, waiting for 45 seconds (9 sleep of 5 seconds each).
This is the portion of code that places images with bar progression:
Fix = gtk_fixed_new ();
image = gtk_image_new_from_file ( "progress1.png");
Gtk_fixed_put (fix, image, 230, 340);
Gtk_container_add (GTK_CONTAINER (win), fix);
Gtk_widget_show_all (Win);
System ( "sleep 5s");
Gtk_container_remove (GTK_CONTAINER (win), fix);
Fix = gtk_fixed_new ();
image = gtk_image_new_from_file ( "progress2.png");
Gtk_fixed_put (fix, image, 230, 340);
Gtk_container_add (GTK_CONTAINER (win), fix);
Gtk_widget_show_all (Win);
System ( "sleep 5s");
Gtk_container_remove (GTK_CONTAINER (win), fix);
Fix = gtk_fixed_new ();
image = gtk_image_new_from_file ( "progress3.png");
Gtk_fixed_put (fix, image, 230, 340);
Gtk_container_add (GTK_CONTAINER (win), fix);
Gtk_widget_show_all (Win);
First I place the beginning progress image, then I remove the container and put the image of progress No. 2 and so on until 10.
If I want that between a picture and another pass 5 seconds, I thought to use the bash command "sleep 5s." The same thing happens if put a for cycle that take few seconds. But this does not appear immediately the window. You'll see the window after 5 seconds, making appear progress10.png, bypassing progress1.png and the other images. So I can not make the ladder progress1.png - 5 seconds - progress2.png - 5 seconds - progress3.png, etc.
Is it possible drawing the window, wait time with the window and objects appeared before remaking the container with new objects inside?
Thanks in advance for helping me.
Scorpion77
|