You call sleep() in mainloop causes it block, you can use g_timeout_*() functions to create event in mainloop in timely manner. Below I modify your code to implement g_timeout_*() functions.
Note, you must care with subwindow creation, user may still create the subwindow (by clicking the OK button) although the subwindow is still displayed. gboolean destroy_subwindow(GtkWidget *subwindow) { gtk_widget_destroy(subwindow); return FALSE; } void subroutine(GtkWidget *button, gpointer data) { GtkWidget *subwindow, *label; subwindow=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(subwindow), 400, 50); label=gtk_label_new("Label"); gtk_container_add(GTK_CONTAINER(subwindow),label); gtk_widget_show_all(subwindow); g_timeout_add (5000, (GSourceFunc) destroy_subwindow, subwindow); /* while (g_main_context_iteration(NULL, FALSE)); */ /* sleep(5); */ /* gtk_widget_destroy(subwindow); */ return; } Regards On Sat, Aug 25, 2012 at 3:41 PM, Frank Cox <thea...@melvilletheatre.com> wrote: > When I click the button the subwindow shows up but the label is missing in > action. > > I thought that this line --> while (g_main_context_iteration(NULL, FALSE)); > > would make both the subwindow and the label show up without having to re-visit > gtk_main(), but obviously that's not the case. Unsurprisingly the window > doesn't show up at all without that line but what happened to the label? > > -- > MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com > www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER! > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list