Looks like you want to update a widget state by running a busy loop in a main loop or by using small delay. If you try this, your widget is never (look) updated.., avoid using sleep or busy loop in the gtk_main() main loop. you should try attach a new source with g_timeout_add*() functions, and set a timeout when the function should be called. Notice that g_timeout_add*() may be delayed.
... static gboolean show_hide (gpointer data) { static gboolean state = TRUE; if (state) { gtk_widget_show (green); gtk_widget_hide (red); state = FALSE; } else { gtk_widget_show (red); gtk_widget_hide (green); state = TRUE; } return TRUE; } ... and in the button callback, try: .... g_timeout_add (200, (GSourceFunc) show_hide, NULL); /* call every 200ms */ .... to remove the source, use g_source_remove(). Another way is to create thread, then call g_idle_add() to set your widgets. --- ajhwb --- adeelmali...@yahoo.com wrote: From: Adeel Malik <adeelmali...@yahoo.com> To: Jim George <jimgeo...@gmail.com> Cc: gtk-app-devel-list@gnome.org Subject: Re: Problem with continuous image updation Date: Wed, 18 Mar 2009 02:31:23 -0700 (PDT) In my application, I am implementing status indication (displaying either 'red' or 'green' ) by using Gdkpixmap to assign an image to 'red' or 'green' pixel array. I display or hide the image by calling gtk_widget_show (..) or gtk_widget_hide(..) once the start button is clicked in the main gtk window. The structure of my application is as follows: int main() { 1. Assign Pixmaps 2. Set up the start button 3. Wait for the start button press 3. rest in gtk_main () } button_function(...) { //while loop while (...) { .. if status=0 { gtk_widget_hide(green); gtk_widget_show(red); } else { gtk_widget_hide(red); gtk_widget_show(green); .... } It appears that gtk is not upating the image during the whole course of while loop (which is running at just 15 cycles/s) based on 'status' variable. However, afer the while loop is finished, I get the updated status image. Could someone suggest what additonal gtk calls I have to make to make sure that the status image is updated (red or green) whenever there is a change in the value of status variable in the while loop of ' start button' function. Thanks, Adeel --- On Tue, 3/10/09, Jim George <jimgeo...@gmail.com> wrote: From: Jim George <jimgeo...@gmail.com> Subject: Re: Continuous variable updation in a text box To: aj...@knac.com Cc: gtk-app-devel-list@gnome.org Date: Tuesday, March 10, 2009, 8:19 PM It wouldn't matter too much, since most screens would only have a refresh rate of 60-120 Hz, which is also much higher than what most people can even see. I've handled such cases by using g_idle_add when I get an update of the variable's status, and have the idle function update the text box. I preserve the event source ID for the next call, and check if that source is still available. If so, I remove the event using g_source_remove and add a new idle event. This way, the most recent update is shown on screen the next time my program goes idle. The idle function then marks the source as free, by setting it to zero. -Jim Ardhan Madras wrote: > So you will need call textbox insertion (update) 1000 times per second or the textbox get updated every 1ms, my question is: Can you see it changes correctly with given cycle? > > --- adeelmali...@yahoo.com wrote: > > From: Adeel Malik <adeelmali...@yahoo.com> > To: gtk-app-devel-list@gnome.org > Subject: Continuous variable updation in a text box > Date: Tue, 10 Mar 2009 02:48:15 -0700 (PDT) > > I intend to monitor the variable's value (acquired via data acquisition hardware) at a rate of around 1,000 times per second. > I haven't used textboxes before in GTK+. Could anyone suggest how to update the value of a variable in a textbox etc., at this rate. > Thanks, > Adeel > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > _____________________________________________________________ > Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _____________________________________________________________ Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list