Re: Updating TextView and StatusBar problem



On Sat, 3 Apr 2004, Miguel Figueiredo wrote:
I created a window which has a textview, a button and a statusbar. When I
press the button, I want to call a func that inserts text in both the
textview and the statusbar over a certain amount of time. The problem is that
this text is only visible when the function ends. The purpose is to display
the text as soon as it is inserted in the textview and/or statusbar.
Hi Miguel,
GTK does its user interface updates in the main loop. When you press the
button the mainloop does not run until your event handler returns, that's
why you don't see the updates of your text changes. To overcome this you
can use
    while (gtk_events_pending()) {
      gtk_main_iteration();
    }
after you changed texts but before the time consuming task. When you
enter your callback you should call gtk_widget_set_sensitive(button,
false) to prevent that the user presses the button again before its first
event handling is finished. Right before exiting the callback enable it
again with gtk_widget_set_sensitive(button, true).

If your task is really time consuming (more than 1 second) you should do
it in a separate thread. A program with a graphical user interface should
always react to user input (like moving/resizing the window) and refresh
its display e.g. after it was covered by another application. Else the
user will think that your program crashed.

Regards,
                            Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]